|
32 | 32 | FIPS_POPULATION_URL = f"https://www2.census.gov/programs-surveys/popest/datasets/2010-{YEAR}/counties/totals/co-est{YEAR}-alldata.csv"
|
33 | 33 | FIPS_PUERTO_RICO_POPULATION_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?"
|
34 | 34 | STATE_HHS_FILE = "hhs.txt"
|
| 35 | +ZIP_POP_MISSING_FILE = "zip_pop_filling.txt" |
35 | 36 |
|
36 | 37 | # Out files
|
37 | 38 | FIPS_STATE_OUT_FILENAME = "fips_state_table.csv"
|
@@ -365,20 +366,13 @@ def derive_zip_population_table():
|
365 | 366 | df = census_pop.merge(fz_df, on="fips", how="left")
|
366 | 367 | df["pop"] = df["pop"].multiply(df["weight"], axis=0)
|
367 | 368 | df = df.drop(columns=["fips", "weight"]).groupby("zip").sum().dropna().reset_index()
|
368 |
| - ## filling population NAs for specific zips on zip_pop_missing Issue #0648 |
369 |
| - ## cheking if each zip still missing, and concatenating if True |
370 |
| - |
371 |
| - zip_pop_missing = pd.DataFrame( |
372 |
| - { |
373 |
| - "zip": ['57756', '57764', '57770', '57772', '57794', '99554', '99563', '99566', |
374 |
| - '99573', '99574', '99581', '99585', '99586', '99604', '99620', '99632', |
375 |
| - '99650', '99657', '99658', '99662', '99666', '99677', '99686', '99693'], |
376 |
| - "pop": [1126, 1923, 5271, 2048, 644, 677, 938, 192, |
377 |
| - 1115, 2348, 762, 417, 605, 1093, 577, 813, |
378 |
| - 568, 329, 329, 480, 189, 88, 4005, 248] |
379 |
| - } |
380 |
| - ) |
381 | 369 |
|
| 370 | + ## loading populatoin of some zips- #Issue 0648 |
| 371 | + zip_pop_missing = pd.read_table( |
| 372 | + ZIP_POP_MISSING_FILE,sep=",", |
| 373 | + dtype={"zip":str,"pop":np.int32} |
| 374 | + ) |
| 375 | + ## cheking if each zip still missing, and concatenating if True |
382 | 376 | for x_zip in zip_pop_missing['zip']:
|
383 | 377 | if x_zip not in df['zip']:
|
384 | 378 | df = pd.concat([df, zip_pop_missing[zip_pop_missing['zip'] == x_zip]],
|
|
0 commit comments