Declining Senior Class Size Chloropleth Map

"Why don't people want to work anymore?" "Why are colleges struggling with enrollment?"

I think part of it just comes down to population trends. This script pulls CCD data (public grade 12 enrollments) and plots the changes from 2012-2019 by county. I wanna expand on this and eventually tie it to occupational trends.

Here's the script to pull data:

import pandas as pd
import requests
import geopandas as gpd
import plotly as px

#create a df starting in 2013 and drop a bunch of columns that aren't need right now
url ='https://educationdata.urban.org/api/v1/schools/ccd/directory/2013/?state_location=NY'
r = requests.get(url)
json = r.json()
df = pd.DataFrame(json['results'])
new_df = df.sort_values(by=['enrollment'],ascending=False)
new_df.drop(columns=['ncessch','leaid','state_leaid','seasch','high_cedp','middle_cedp','ungrade_cedp','state_leg_district_lower','state_leg_district_upper','ncessch_num','congress_district_id','direct_certification','lunch_program','magnet','shared_time','virtual','teachers_fte','free_lunch','reduced_price_lunch','free_or_reduced_price_lunch','elem_cedp','bureau_indian_education','title_i_status','title_i_eligible','title_i_schoolwide','charter','highest_grade_offered','lowest_grade_offered','school_status','school_type','school_level','urban_centric_locale','cbsa','csa','phone'],inplace=True)

#function to loop through and add a new column for enrollment by year
def add_years():
for i in range(14,21):
global new_df
url ='https://educationdata.urban.org/api/v1/schools/ccd/directory/' + '20'+ str(i) + '/?state_location=NY'
r = requests.get(url)
json = r.json()
df = pd.DataFrame(json['results'])
new = df.filter(['school_id','enrollment'], axis=1)
new.rename(columns = {'enrollment':'enrollment'+str(i)}, inplace = True)
new_df = new_df.merge(new, on='school_id', how='left')
return new_df

add_years()


new_df['enrollment_change'] = new_df['enrollment19'] - new_df['enrollment']
fips_table = new_df.filter(['county_code','enrollment','enrollment19','enrollment_change'], axis=1)
fips_table = fips_table.groupby('county_code',as_index=False).sum()
fips_table['%_change'] = (fips_table['enrollment19'] - fips_table['enrollment']) / fips_table['enrollment']*100

And to create the chloropleth map:

from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)


import plotly.express as px

fig = px.choropleth(fips_table, geojson=counties, locations='county_code', color='%_change',
color_continuous_scale=["red",'white', "green"],
range_color=(-15, 15),
scope="usa",
labels={'unemp':'unemployment rate'}
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()