Code
!pip install geopandas hvplot panel
Finally, we can make a map to see how the variables vary across US states.
The map shows that there are large variations in median household income, education levels, unemployment rate, labour force participation rate, labour productivity, population, poverty rate across US states. There are moderate variations in life expectancy, with all states having life expectancy greater than 70. There is small variations in GDP per capita and net exports across states.
!pip install geopandas hvplot panel
import geopandas as gpd
import hvplot.pandas
import panel as pn
# Convert from wide to long data
= pd.melt(us_rescaled_final,
us_rescaled_final_long = ['STATEFP', 'STATENS', 'GEOIDFQ', 'GEOID', 'STUSPS', 'NAME_x', 'LSAD','ALAND', 'AWATER', 'geometry', 'NAME_y', 'GEO_ID'],
id_vars =['MedHHInc', 'EducTotal', 'EducBelowHighSch', 'EducHighSch', 'EducAssoc', 'EducBach', 'TotalPop', 'TotalPop16', 'LabForTotal', 'Unemployed', 'PopPovertyDetermined', 'PovertyPop', 'PctBach', 'PovertyRate', 'UnemploymentRate', 'LabForParticipationRate', 'netexport', 'REALGDP', 'life_expectancy', 'Labor_Productivity_2023', 'REALGDPpercapita']
value_vars )
= us_rescaled_final_long.hvplot(
chart3 ="value",
c=False,
dynamic=1000,
width=1000,
height=True,
geo="viridis",
cmap="variable") groupby
chart3