Skip to content

Commit efbb07e

Browse files
committed
added the missing population in a txt file
1 parent bd536ce commit efbb07e

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

_delphi_utils_python/data_proc/geomap/geo_data_proc.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
FIPS_POPULATION_URL = f"https://www2.census.gov/programs-surveys/popest/datasets/2010-{YEAR}/counties/totals/co-est{YEAR}-alldata.csv"
3333
FIPS_PUERTO_RICO_POPULATION_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?"
3434
STATE_HHS_FILE = "hhs.txt"
35+
ZIP_POP_MISSING_FILE = "zip_pop_filling.txt"
3536

3637
# Out files
3738
FIPS_STATE_OUT_FILENAME = "fips_state_table.csv"
@@ -365,20 +366,13 @@ def derive_zip_population_table():
365366
df = census_pop.merge(fz_df, on="fips", how="left")
366367
df["pop"] = df["pop"].multiply(df["weight"], axis=0)
367368
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-
)
381369

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
382376
for x_zip in zip_pop_missing['zip']:
383377
if x_zip not in df['zip']:
384378
df = pd.concat([df, zip_pop_missing[zip_pop_missing['zip'] == x_zip]],
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
zip,pop
2+
57756,1126
3+
57764,1923
4+
57770,5271
5+
57772,2048
6+
57794,644
7+
99554,677
8+
99563,938
9+
99566,192
10+
99573,1115
11+
99574,2348
12+
99581,762
13+
99585,417
14+
99586,605
15+
99604,1093
16+
99620,577
17+
99632,813
18+
99650,568
19+
99657,329
20+
99658,616
21+
99662,480
22+
99666,189
23+
99677,88
24+
99686,4005
25+
99693,248

0 commit comments

Comments
 (0)