Interactive widgets

At the beginning of the chapter, you learned how to query and map incidents based on a date. In Jupyter, you can use interactive widgets to change values. The code will help us in how you can use ipywidgets to import interact, which will allow you to insert a DatePicker so that you can select a date to interact with the Notebook:

The previous code imports interact and the DatePicker widget. At its simplest, the previous screenshot shows a decorator and function to allow interactively selecting a date and displaying it as a string.

When the DatePicker changes, x (the DatePicker) is sent to the function theDate(x), and

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.