Locating farmers markets
This notebook uses Jupyter widgets to explore the farmers markets dataset. Jupyter widgets can make exploring data and working with notebooks easier and more interactive.
First, install the ipyleaflet Python package. We'll use this later to display geographic data on maps.
Read the farmers market data from databricks-datasets
as a pandas DataFrame.
The dataset is over 8000 rows and nearly 60 columns, so viewing it all at once is not practical, but you can use ipywidgets to display subsets of the data.
Now you have a better idea of what kind of data is in the table. Suppose you want to know what markets are available in San Francisco and where they are. You can use a map widget from ipyleaflet to display the location of all the San Francisco farmers markets on an interactive map. You can then zoom in and see the exact location of each market.
This map is nice, but it's a bit hard to know which market you're looking at on the map. You can redo the markers on the map so that an information popup appears when you click on them. To do this, use the HTML widget to display the name and time for each market. The code below changes the map above, so after you evaluate the cell below, scroll back up to the map to see the changes.
To identify markets that sell your favorite foods, add a multiple-select widget to the map to filter the markets based on what you want to buy.
At this point, you've found a market for this weekend, and in the process, you've built a small data application. You can make the application a little more general so you can use it for other areas as well. In the following cell, you add a refresh button to update the markets displayed to match the visible area of the map.