Skip to content

Commit 8bd9ca4

Browse files
authored
Manually add population for national data (#1938)
1 parent e96236b commit 8bd9ca4

File tree

1 file changed

+4
-1
lines changed
  • nchs_mortality/delphi_nchs_mortality

1 file changed

+4
-1
lines changed

nchs_mortality/delphi_nchs_mortality/pull.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def pull_nchs_mortality_data(token: str, test_file: Optional[str]=None):
127127
geocode_col="state", dropna=False)
128128
df = gmpr.add_geocode(df, "state_name", "state_id",
129129
from_col="state", new_col="geo_id", dropna=False)
130-
# Manually set geo_id for national data
130+
# Manually set geo_id and population for national data
131+
national_pop = gmpr.get_crosswalk("nation", "pop")
132+
us_pop = national_pop.loc[national_pop["nation"] == "us"]["pop"][0]
133+
df.loc[df["state"] == "United States", "population"] = us_pop
131134
df.loc[df["state"] == "United States", "geo_id"] = "us"
132135
return df[keep_columns]

0 commit comments

Comments
 (0)