Download sets.py from dastacey/population_dashboard_version1: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/dastacey/population_dashboard_version1/resolve/main/sets.py
- Command line
-
hf download hf://spaces/dastacey/population_dashboard_version1/sets.py
-
curl -L -o sets.py https://huggingface.co/spaces/dastacey/population_dashboard_version1/resolve/main/sets.py
1.24 kB
| import gradio as gr | |
| import pandas as pd | |
| from datetime import datetime | |
| import config as cf | |
| import gets as gs | |
| # Reset Year Range for selected dataset | |
| def resetYearRange(countryDropdown,slider_1,slider_2): | |
| cf.Globals.country = cf.Globals.countriesList[countryDropdown] | |
| cf.Globals.df_country = cf.Globals.df_all[cf.Globals.df_all["country"]==cf.Globals.country] | |
| yearList = sorted(set(cf.Globals.df_country['year'])) | |
| cf.Globals.startYear = yearList[0] | |
| cf.Globals.endYear = yearList[-1] | |
| return ( gr.Slider(minimum=cf.Globals.startYear, maximum=cf.Globals.endYear, step=1, value=cf.Globals.startYear, label="Start Year"), | |
| gr.Slider(minimum=cf.Globals.startYear, maximum=cf.Globals.endYear, step=1, value=cf.Globals.endYear, label="End Year") ) | |
| def resetSpecies ( countryDropdown, speciesDropdown ): | |
| cf.Globals.country = cf.Globals.countriesList[countryDropdown] | |
| cf.Globals.df_country = cf.Globals.df_all[cf.Globals.df_all["country"]==cf.Globals.country] | |
| gs.getSpecies(cf.Globals.df_country) | |
| gs.getYearRange(cf.Globals.df_country) | |
| return gr.Dropdown( choices=cf.Globals.speciesList, type="value", value=cf.Globals.species, multiselect=True, label="Species", info="Select Species" ) | |