"""Reproduce descriptive headline statistics from the accompanying 120-county CSV. Python 3; dependency: pandas. No internet connectivity required. Numbers are ACS 2020-2024 point estimates via FRED; not causal results. """ from pathlib import Path import pandas as pd src=Path(__file__).with_name('120_county_ACS_verified.csv') df=pd.read_csv(src) assert len(df)==120 and df.County.nunique()==120 p='Poverty_pct_2020_2024'; b='Bachelors_pct_2020_2024'; flag='SustainedPoverty_4_Periods' assert df[p].notna().all() and df[b].notna().all() s=df.loc[df[flag].eq('Yes')] report={ 'total_counties':len(df), 'current_poverty_at_least_20_counties':int(df[p].ge(20).sum()), 'sustained_poverty_counties':len(s), 'current_high_not_sustained':int((df[p].ge(20)&df[flag].eq('No')).sum()), 'poverty_median_unweighted':round(df[p].median(),2), 'poverty_mean_unweighted':round(df[p].mean(),2), 'degree_median_unweighted':round(df[b].median(),2), 'pearson_ecological_r':round(df[[p,b]].corr().iloc[0,1],3), 'spearman_ecological_rho':round(df[[p,b]].corr(method='spearman').iloc[0,1],3), 'historic_35_mean_2005_2009':round(s.Pov_2005_2009.mean(),2), 'historic_35_mean_2020_2024':round(s[p].mean(),2), 'historic_35_count_declined':int((s[p]s.Pov_2005_2009).sum()), 'observed_2025_unemployment_counties':int(df.Unemployment_2025_pct.notna().sum()) } for key,value in report.items():print(f'{key}: {value}') assert report['current_poverty_at_least_20_counties']==47 assert report['sustained_poverty_counties']==35 assert report['current_high_not_sustained']==12 assert report['observed_2025_unemployment_counties']==23