Skip to content

Commit 0a7865e

Browse files
authored
Merge pull request #354 from cmu-delphi/lowercase-cdcnet
cdc_covidnet: change states to lowercase to align with geo_util default
2 parents c9fea0a + f4b4eb4 commit 0a7865e

File tree

4 files changed

+33
-35
lines changed

4 files changed

+33
-35
lines changed

cdc_covidnet/delphi_cdc_covidnet/update_sensor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def update_sensor(
9292
new_code="state_id",
9393
dropna=False)
9494
# To use the original column name, reassign original column and drop new one
95-
hosp_df[APIConfig.STATE_COL] = hosp_df["state_id"].str.upper()
95+
hosp_df[APIConfig.STATE_COL] = hosp_df["state_id"]
9696
hosp_df.drop("state_id", axis=1, inplace=True)
9797
assert not hosp_df.duplicated(["date", "geo_id"]).any(), "Non-unique (date, geo_id) pairs"
9898
hosp_df.set_index(["date", "geo_id"], inplace=True)
@@ -105,7 +105,6 @@ def update_sensor(
105105
signals = add_prefix(SIGNALS, wip_signal=read_params()["wip_signal"], prefix="wip_")
106106
for signal in signals:
107107
write_to_csv(hosp_df, signal, output_path)
108-
109108
return hosp_df
110109

111110

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
geo_id,val,se,sample_size
2-
CA,0.2,NA,NA
3-
CO,0.1,NA,NA
4-
CT,0.1,NA,NA
5-
GA,0.5,NA,NA
6-
MD,0.1,NA,NA
7-
MN,0.0,NA,NA
8-
NM,0.0,NA,NA
9-
NY,0.1,NA,NA
10-
OR,0.1,NA,NA
11-
TN,0.1,NA,NA
12-
IA,0.0,NA,NA
13-
MI,0.1,NA,NA
14-
OH,0.0,NA,NA
15-
UT,0.0,NA,NA
2+
ca,0.2,NA,NA
3+
co,0.1,NA,NA
4+
ct,0.1,NA,NA
5+
ga,0.5,NA,NA
6+
md,0.1,NA,NA
7+
mn,0.0,NA,NA
8+
nm,0.0,NA,NA
9+
ny,0.1,NA,NA
10+
or,0.1,NA,NA
11+
tn,0.1,NA,NA
12+
ia,0.0,NA,NA
13+
mi,0.1,NA,NA
14+
oh,0.0,NA,NA
15+
ut,0.0,NA,NA
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
geo_id,val,se,sample_size
2-
CA,1.0,NA,NA
3-
CO,0.8,NA,NA
4-
CT,1.0,NA,NA
5-
GA,2.7,NA,NA
6-
MD,0.4,NA,NA
7-
MN,0.1,NA,NA
8-
NM,0.2,NA,NA
9-
NY,0.7,NA,NA
10-
OR,0.5,NA,NA
11-
TN,0.7,NA,NA
12-
IA,0.0,NA,NA
13-
MI,0.2,NA,NA
14-
OH,0.3,NA,NA
15-
UT,0.2,NA,NA
2+
ca,1.0,NA,NA
3+
co,0.8,NA,NA
4+
ct,1.0,NA,NA
5+
ga,2.7,NA,NA
6+
md,0.4,NA,NA
7+
mn,0.1,NA,NA
8+
nm,0.2,NA,NA
9+
ny,0.7,NA,NA
10+
or,0.5,NA,NA
11+
tn,0.7,NA,NA
12+
ia,0.0,NA,NA
13+
mi,0.2,NA,NA
14+
oh,0.3,NA,NA
15+
ut,0.2,NA,NA

cdc_covidnet/tests/test_update_sensor.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,16 @@ def test_syn_update_sensor(self):
7676

7777
# Generate the csvs
7878
hosp_df = update_sensor(state_files, mmwr_info, temp_dir, start_date, end_date)
79-
8079
# Check dataframe returned
8180
assert hosp_df.index.nlevels == 2
8281
assert set(hosp_df.index.names) == {"date", "geo_id"}
83-
assert set(hosp_df.index.get_level_values("geo_id")) == {"CA", "PA"}
82+
assert set(hosp_df.index.get_level_values("geo_id")) == {"ca", "pa"}
8483
assert set(hosp_df.index.get_level_values("date")) == \
8584
{datetime(2020, 3, 7), datetime(2020, 3, 14)}
8685
assert set(hosp_df["epiweek"].unique()) == {10, 11}
8786
geo_index = hosp_df.index.get_level_values("geo_id")
88-
assert np.allclose(hosp_df.loc[geo_index == "CA", "val"], [2.5, 3.5])
89-
assert np.allclose(hosp_df.loc[geo_index == "PA", "val"], [10.3, 11.2])
87+
assert np.allclose(hosp_df.loc[geo_index == "ca", "val"], [2.5, 3.5])
88+
assert np.allclose(hosp_df.loc[geo_index == "pa", "val"], [10.3, 11.2])
9089
assert pd.isna(hosp_df["se"]).all()
9190
assert pd.isna(hosp_df["sample_size"]).all()
9291

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

110109
# Check values are right
111-
assert set(data["geo_id"].unique()) == {"CA", "PA"}
110+
assert set(data["geo_id"].unique()) == {"ca", "pa"}
112111
assert np.allclose(
113112
data["val"], [
114113
state_1["datadownload"][i]["cumulative-rate"],

0 commit comments

Comments
 (0)