Skip to content

Commit ad089cf

Browse files
authored
add hhs geo level (#2036)
1 parent 2184da7 commit ad089cf

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

_delphi_utils_python/delphi_utils/geomap.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def add_population_column(
443443
---------
444444
data: pd.DataFrame
445445
The dataframe with a FIPS code column.
446-
geocode_type: {"fips", "zip"}
446+
geocode_type:
447447
The type of the geocode contained in geocode_col.
448448
geocode_col: str, default None
449449
The name of the column containing the geocodes. If None, uses the geocode_type
@@ -671,8 +671,10 @@ def aggregate_by_weighted_sum(
671671
to a from_geo, e.g. "wastewater collection site").
672672
to_geo: str
673673
The column name of the geocode to aggregate to.
674-
sensor: str
674+
sensor_col: str
675675
The column name of the sensor to aggregate.
676+
time_col: str
677+
The column name of the timestamp to aggregate over.
676678
population_column: str
677679
The column name of the population to weight the sensor by.
678680

nssp/delphi_nssp/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"nation",
77
"state",
88
"county",
9+
"hhs",
910
]
1011

1112
SIGNALS_MAP = {

nssp/delphi_nssp/run.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ def run_module(params):
111111
df = geo_mapper.add_geocode(df, "fips", "msa", from_col="fips", new_col="geo_id")
112112
df = geo_mapper.aggregate_by_weighted_sum(df, "geo_id", "val", "timestamp", "population")
113113
df = df.rename(columns={"weighted_val": "val"})
114+
elif geo == "hhs":
115+
df = df[(df["county"] == "All") & (df["geography"] != "United States")]
116+
df = df[["geography", "val", "timestamp"]]
117+
df = geo_mapper.add_population_column(df, geocode_type="state_name", geocode_col="geography")
118+
df = geo_mapper.add_geocode(df, "state_name", "state_code", from_col="state_name")
119+
df = geo_mapper.add_geocode(df, "state_code", "hhs", from_col="state_code", new_col="geo_id")
120+
df = geo_mapper.aggregate_by_weighted_sum(df, "geo_id", "val", "timestamp", "population")
121+
df = df.rename(columns={"weighted_val": "val"})
114122
else:
115123
df = df[df["county"] != "All"]
116124
df["geo_id"] = df["fips"]

0 commit comments

Comments
 (0)