Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nssp/delphi_nssp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"state",
"county",
"hhs",
"hsanci",
]

SIGNALS_MAP = {
Expand Down
2 changes: 1 addition & 1 deletion nssp/delphi_nssp/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ def pull_nssp_data(
# Format county fips to all be 5 digits with leading zeros
df_ervisits["fips"] = df_ervisits["fips"].apply(lambda x: str(x).zfill(5) if str(x) != "0" else "0")

keep_columns = ["timestamp", "geography", "county", "fips"]
keep_columns = ["timestamp", "geography", "county", "fips", "hsa_nci_id"]
return df_ervisits[SIGNALS + keep_columns]
6 changes: 6 additions & 0 deletions nssp/delphi_nssp/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def add_needed_columns(df, col_names=None):
df = add_default_nancodes(df)
return df


def logging(start_time, run_stats, logger):
"""Boilerplate making logs."""
elapsed_time_in_seconds = round(time.time() - start_time, 2)
Expand Down Expand Up @@ -137,6 +138,11 @@ def run_module(params, logger=None):
df = geo_mapper.add_geocode(df, "state_code", "hhs", from_col="state_code", new_col="geo_id")
df = geo_mapper.aggregate_by_weighted_sum(df, "geo_id", "val", "timestamp", "population")
df = df.rename(columns={"weighted_val": "val"})
elif geo == "hsanci":
df = df[["hsa_nci_id", "val", "timestamp"]]
df = df[df["hsa_nci_id"] != "All"]
df = df.groupby(["hsa_nci_id", "timestamp"])["val"].min().reset_index()
df = df.rename(columns={"hsa_nci_id": "geo_id"})
else:
df = df[df["county"] != "All"]
df["geo_id"] = df["fips"]
Expand Down