Skip to content

Commit

Permalink
Manually add population for national data (#1938)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzats authored Jan 25, 2024
1 parent e96236b commit 8bd9ca4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nchs_mortality/delphi_nchs_mortality/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def pull_nchs_mortality_data(token: str, test_file: Optional[str]=None):
geocode_col="state", dropna=False)
df = gmpr.add_geocode(df, "state_name", "state_id",
from_col="state", new_col="geo_id", dropna=False)
# Manually set geo_id for national data
# Manually set geo_id and population for national data
national_pop = gmpr.get_crosswalk("nation", "pop")
us_pop = national_pop.loc[national_pop["nation"] == "us"]["pop"][0]
df.loc[df["state"] == "United States", "population"] = us_pop
df.loc[df["state"] == "United States", "geo_id"] = "us"
return df[keep_columns]

0 comments on commit 8bd9ca4

Please sign in to comment.