|
20 | 20 |
|
21 | 21 |
|
22 | 22 | # Source files |
| 23 | +YEAR = 2019 |
23 | 24 | INPUT_DIR = "./old_source_files" |
24 | | -OUTPUT_DIR = "../../delphi_utils/data" |
| 25 | +OUTPUT_DIR = f"../../delphi_utils/data/{YEAR}" |
25 | 26 | FIPS_BY_ZIP_POP_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?#" |
26 | 27 | ZIP_HSA_HRR_URL = "https://atlasdata.dartmouth.edu/downloads/geography/ZipHsaHrr18.csv.zip" |
27 | 28 | ZIP_HSA_HRR_FILENAME = "ZipHsaHrr18.csv" |
28 | 29 | FIPS_MSA_URL = "https://www2.census.gov/programs-surveys/metro-micro/geographies/reference-files/2018/delineation-files/list1_Sep_2018.xls" |
29 | 30 | JHU_FIPS_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv" |
30 | 31 | STATE_CODES_URL = "http://www2.census.gov/geo/docs/reference/state.txt?#" |
31 | | -FIPS_POPULATION_URL = "https://www2.census.gov/programs-surveys/popest/datasets/2010-2020/counties/totals/co-est2020-alldata.csv" |
| 32 | +FIPS_POPULATION_URL = f"https://www2.census.gov/programs-surveys/popest/datasets/2010-{YEAR}/counties/totals/co-est{YEAR}-alldata.csv" |
32 | 33 | FIPS_PUERTO_RICO_POPULATION_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?" |
33 | 34 | STATE_HHS_FILE = "hhs.txt" |
34 | 35 |
|
@@ -265,11 +266,11 @@ def create_state_hhs_crosswalk(): |
265 | 266 | def create_fips_population_table(): |
266 | 267 | """Build a table of populations by FIPS county codes. |
267 | 268 |
|
268 | | - Uses US Census Bureau population data from 2020, with 2010 population data for Puerto Rico and a few exceptions. |
| 269 | + Uses US Census Bureau population data as determined by the YEAR variable, with 2010 population data for Puerto Rico and a few exceptions. |
269 | 270 | """ |
270 | 271 | census_pop = pd.read_csv(FIPS_POPULATION_URL, encoding="ISO-8859-1") |
271 | 272 | census_pop["fips"] = census_pop.apply(lambda x: f"{x['STATE']:02d}{x['COUNTY']:03d}", axis=1) |
272 | | - census_pop = census_pop.rename(columns={"POPESTIMATE2020": "pop"})[["fips", "pop"]] |
| 273 | + census_pop = census_pop.rename(columns={f"POPESTIMATE{YEAR}": "pop"})[["fips", "pop"]] |
273 | 274 |
|
274 | 275 | # Set population for Dukes and Nantucket combo county |
275 | 276 | dukes_pop = int(census_pop.loc[census_pop["fips"] == "25007", "pop"]) |
|
0 commit comments