Skip to content

cdc_covidnet: change states to lowercase to align with geo_util default #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions cdc_covidnet/delphi_cdc_covidnet/update_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def update_sensor(
new_code="state_id",
dropna=False)
# To use the original column name, reassign original column and drop new one
hosp_df[APIConfig.STATE_COL] = hosp_df["state_id"].str.upper()
hosp_df[APIConfig.STATE_COL] = hosp_df["state_id"]
hosp_df.drop("state_id", axis=1, inplace=True)
assert not hosp_df.duplicated(["date", "geo_id"]).any(), "Non-unique (date, geo_id) pairs"
hosp_df.set_index(["date", "geo_id"], inplace=True)
Expand All @@ -105,7 +105,6 @@ def update_sensor(
signals = add_prefix(SIGNALS, wip_signal=read_params()["wip_signal"], prefix="wip_")
for signal in signals:
write_to_csv(hosp_df, signal, output_path)

return hosp_df


Expand Down
28 changes: 14 additions & 14 deletions cdc_covidnet/tests/receiving_test/202010_state_wip_covidnet.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
geo_id,val,se,sample_size
CA,0.2,NA,NA
CO,0.1,NA,NA
CT,0.1,NA,NA
GA,0.5,NA,NA
MD,0.1,NA,NA
MN,0.0,NA,NA
NM,0.0,NA,NA
NY,0.1,NA,NA
OR,0.1,NA,NA
TN,0.1,NA,NA
IA,0.0,NA,NA
MI,0.1,NA,NA
OH,0.0,NA,NA
UT,0.0,NA,NA
ca,0.2,NA,NA
co,0.1,NA,NA
ct,0.1,NA,NA
ga,0.5,NA,NA
md,0.1,NA,NA
mn,0.0,NA,NA
nm,0.0,NA,NA
ny,0.1,NA,NA
or,0.1,NA,NA
tn,0.1,NA,NA
ia,0.0,NA,NA
mi,0.1,NA,NA
oh,0.0,NA,NA
ut,0.0,NA,NA
28 changes: 14 additions & 14 deletions cdc_covidnet/tests/receiving_test/202011_state_wip_covidnet.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
geo_id,val,se,sample_size
CA,1.0,NA,NA
CO,0.8,NA,NA
CT,1.0,NA,NA
GA,2.7,NA,NA
MD,0.4,NA,NA
MN,0.1,NA,NA
NM,0.2,NA,NA
NY,0.7,NA,NA
OR,0.5,NA,NA
TN,0.7,NA,NA
IA,0.0,NA,NA
MI,0.2,NA,NA
OH,0.3,NA,NA
UT,0.2,NA,NA
ca,1.0,NA,NA
co,0.8,NA,NA
ct,1.0,NA,NA
ga,2.7,NA,NA
md,0.4,NA,NA
mn,0.1,NA,NA
nm,0.2,NA,NA
ny,0.7,NA,NA
or,0.5,NA,NA
tn,0.7,NA,NA
ia,0.0,NA,NA
mi,0.2,NA,NA
oh,0.3,NA,NA
ut,0.2,NA,NA
9 changes: 4 additions & 5 deletions cdc_covidnet/tests/test_update_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,16 @@ def test_syn_update_sensor(self):

# Generate the csvs
hosp_df = update_sensor(state_files, mmwr_info, temp_dir, start_date, end_date)

# Check dataframe returned
assert hosp_df.index.nlevels == 2
assert set(hosp_df.index.names) == {"date", "geo_id"}
assert set(hosp_df.index.get_level_values("geo_id")) == {"CA", "PA"}
assert set(hosp_df.index.get_level_values("geo_id")) == {"ca", "pa"}
assert set(hosp_df.index.get_level_values("date")) == \
{datetime(2020, 3, 7), datetime(2020, 3, 14)}
assert set(hosp_df["epiweek"].unique()) == {10, 11}
geo_index = hosp_df.index.get_level_values("geo_id")
assert np.allclose(hosp_df.loc[geo_index == "CA", "val"], [2.5, 3.5])
assert np.allclose(hosp_df.loc[geo_index == "PA", "val"], [10.3, 11.2])
assert np.allclose(hosp_df.loc[geo_index == "ca", "val"], [2.5, 3.5])
assert np.allclose(hosp_df.loc[geo_index == "pa", "val"], [10.3, 11.2])
assert pd.isna(hosp_df["se"]).all()
assert pd.isna(hosp_df["sample_size"]).all()

Expand All @@ -108,7 +107,7 @@ def test_syn_update_sensor(self):
assert pd.isna(data["sample_size"]).all()

# Check values are right
assert set(data["geo_id"].unique()) == {"CA", "PA"}
assert set(data["geo_id"].unique()) == {"ca", "pa"}
assert np.allclose(
data["val"], [
state_1["datadownload"][i]["cumulative-rate"],
Expand Down