Incorporating the function into the app
Here is the plan for the functionality that we are going to introduce:
- Create a drop-down list using the countries and regions available in our dataset.
- Create a callback function that takes the selected country, filters the dataset, and finds the population of that country in the year 2010.
- Return a small report about the found data. Figure 2.7 shows the desired end result:
Important note
Now that we are beginning to use our dataset, we will start opening files from the data
folder. This assumes that the app you are running is in the same folder. The code for each chapter in the GitHub repository is placed in its own folder for easy access; however, the code only works if the data
folder and app.py
are both in the same folder.
Figure 2.8 shows what this folder structure might look like: