Skip to content

Commit a1c2f61

Browse files
committed
add hsanci code logic
1 parent 166ea2c commit a1c2f61

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

nssp/delphi_nssp/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"state",
1010
"county",
1111
"hhs",
12+
"hsanci",
1213
]
1314

1415
SIGNALS_MAP = {

nssp/delphi_nssp/pull.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,5 @@ def pull_nssp_data(
177177
# Format county fips to all be 5 digits with leading zeros
178178
df_ervisits["fips"] = df_ervisits["fips"].apply(lambda x: str(x).zfill(5) if str(x) != "0" else "0")
179179

180-
keep_columns = ["timestamp", "geography", "county", "fips"]
180+
keep_columns = ["timestamp", "geography", "county", "fips", "hsa_nci_id"]
181181
return df_ervisits[SIGNALS + keep_columns]

nssp/delphi_nssp/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ def run_module(params, logger=None):
137137
df = geo_mapper.add_geocode(df, "state_code", "hhs", from_col="state_code", new_col="geo_id")
138138
df = geo_mapper.aggregate_by_weighted_sum(df, "geo_id", "val", "timestamp", "population")
139139
df = df.rename(columns={"weighted_val": "val"})
140+
elif geo == "hsanci":
141+
df = df[["hsa_nci_id", "val", "timestamp"]]
142+
df = df[df["hsa_nci_id"] != "All"]
143+
df = df.groupby(["hsa_nci_id", "timestamp"])['val'].min().reset_index()
144+
df = df.rename(columns={"hsa_nci_id": "geo_id"})
140145
else:
141146
df = df[df["county"] != "All"]
142147
df["geo_id"] = df["fips"]

0 commit comments

Comments
 (0)