Skip to content

Commit 90aafdd

Browse files
committed
rename to hhs
1 parent d8b6ab6 commit 90aafdd

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

_delphi_utils_python/data_proc/geomap/geo_data_proc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
ZIP_STATE_CODE_OUT_FILENAME = "zip_state_code_table.csv"
4646
ZIP_HHS_FILENAME = "zip_hhs_table.csv"
4747
STATE_OUT_FILENAME = "state_codes_table.csv"
48-
STATE_HHS_OUT_FILENAME = "state_code_hhs_region_number_table.csv"
48+
STATE_HHS_OUT_FILENAME = "state_code_hhs_table.csv"
4949
JHU_FIPS_OUT_FILENAME = "jhu_uid_fips_table.csv"
5050

5151

@@ -334,12 +334,12 @@ def create_state_hhs_crosswalk():
334334
hhs_state_pairs.append((9, "Northern Mariana Islands"))
335335

336336
# Make dataframe
337-
hhs_df = pd.DataFrame(hhs_state_pairs, columns=["hhs_region_number", "state_name"])
338-
hhs_df["hhs_region_number"] = hhs_df["hhs_region_number"].astype(str)
337+
hhs_df = pd.DataFrame(hhs_state_pairs, columns=["hhs", "state_name"])
338+
hhs_df["hhs"] = hhs_df["hhs"].astype(str)
339339

340340
(
341341
ss_df.merge(hhs_df, on="state_name", how="left")
342-
.dropna()[["state_code", "hhs_region_number"]]
342+
.dropna()[["state_code", "hhs"]]
343343
.to_csv(join(OUTPUT_DIR, STATE_HHS_OUT_FILENAME), index=False)
344344
)
345345

_delphi_utils_python/delphi_utils/data/fips_hhs_table.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fips,hhs_region_number
1+
fips,hhs
22
01000,4
33
01001,4
44
01003,4

_delphi_utils_python/delphi_utils/data/state_code_hhs_region_number_table.csv renamed to _delphi_utils_python/delphi_utils/data/state_code_hhs_table.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
state_code,hhs_region_number
1+
state_code,hhs
22
01,4
33
02,10
44
04,9

_delphi_utils_python/delphi_utils/data/zip_hhs_table.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
zip,weight,hhs_region_number
1+
zip,weight,hhs
22
601,0.994345718901454,2
33
601,0.005654281098546043,2
44
602,1.0,2

_delphi_utils_python/delphi_utils/geomap.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
"msa": join(DATA_PATH, "zip_msa_table.csv"),
2323
"pop": join(DATA_PATH, "zip_pop.csv"),
2424
"state": join(DATA_PATH, "zip_state_code_table.csv"),
25-
"hhs_region_number": join(DATA_PATH, "zip_hhs_table.csv")
25+
"hhs": join(DATA_PATH, "zip_hhs_table.csv")
2626
},
2727
"fips": {
2828
"zip": join(DATA_PATH, "fips_zip_table.csv"),
2929
"hrr": join(DATA_PATH, "fips_hrr_table.csv"),
3030
"msa": join(DATA_PATH, "fips_msa_table.csv"),
3131
"pop": join(DATA_PATH, "fips_pop.csv"),
3232
"state": join(DATA_PATH, "fips_state_table.csv"),
33-
"hhs_region_number": join(DATA_PATH, "fips_hhs_table.csv"),
33+
"hhs": join(DATA_PATH, "fips_hhs_table.csv"),
3434
},
3535
"state": {"state": join(DATA_PATH, "state_codes_table.csv")},
3636
"state_code": {
37-
"hhs_region_number": join(DATA_PATH, "state_code_hhs_region_number_table.csv")
37+
"hhs": join(DATA_PATH, "state_code_hhs_table.csv")
3838
},
3939
"jhu_uid": {"fips": join(DATA_PATH, "jhu_uid_fips_table.csv")},
4040
}
@@ -57,14 +57,14 @@ class GeoMapper: # pylint: disable=too-many-public-methods
5757
- [x] zip -> hrr : unweighted
5858
- [x] zip -> msa : unweighted
5959
- [x] zip -> state
60-
- [x] zip -> hhs_region_number
60+
- [x] zip -> hhs
6161
- [x] zip -> population
62-
- [x] state code -> hhs_region_number
62+
- [x] state code -> hhs
6363
- [x] fips -> state : unweighted
6464
- [x] fips -> msa : unweighted
6565
- [x] fips -> megacounty
6666
- [x] fips -> hrr
67-
- [x] fips -> hhs_region_number
67+
- [x] fips -> hhs
6868
- [x] nation
6969
- [ ] zip -> dma (postponed)
7070
@@ -107,13 +107,13 @@ def __init__(self):
107107
self.crosswalk_filepaths = CROSSWALK_FILEPATHS
108108
self.crosswalks = {
109109
"zip": {
110-
geo: None for geo in ["fips", "hrr", "msa", "pop", "state", "hhs_region_number"]
110+
geo: None for geo in ["fips", "hrr", "msa", "pop", "state", "hhs"]
111111
},
112112
"fips": {
113-
geo: None for geo in ["zip", "hrr", "msa", "pop", "state", "hhs_region_number"]
113+
geo: None for geo in ["zip", "hrr", "msa", "pop", "state", "hhs"]
114114
},
115115
"state": {"state": None},
116-
"state_code": {"hhs_region_number": None},
116+
"state_code": {"hhs": None},
117117
"jhu_uid": {"fips": None},
118118
}
119119

@@ -131,7 +131,7 @@ def _load_crosswalk(self, from_code, to_code):
131131
("jhu_uid", "fips"),
132132
("zip", "msa"),
133133
("fips", "hrr"),
134-
("zip", "hhs_region_number")
134+
("zip", "hhs")
135135
]:
136136
self.crosswalks[from_code][to_code] = pd.read_csv(
137137
stream,
@@ -145,8 +145,8 @@ def _load_crosswalk(self, from_code, to_code):
145145
elif (from_code, to_code) in [
146146
("zip", "hrr"),
147147
("fips", "msa"),
148-
("fips", "hhs_region_number"),
149-
("state_code", "hhs_region_number")
148+
("fips", "hhs"),
149+
("state_code", "hhs")
150150
]:
151151
self.crosswalks[from_code][to_code] = pd.read_csv(
152152
stream,
@@ -261,11 +261,11 @@ def add_geocode(
261261
"""Add a new geocode column to a dataframe.
262262
263263
Currently supported conversions:
264-
- fips -> state_code, state_id, state_name, zip, msa, hrr, nation, hhs_region_number
265-
- zip -> state_code, state_id, state_name, fips, msa, hrr, nation, hhs_region_number
264+
- fips -> state_code, state_id, state_name, zip, msa, hrr, nation, hhs
265+
- zip -> state_code, state_id, state_name, fips, msa, hrr, nation, hhs
266266
- jhu_uid -> fips
267267
- state_x -> state_y, where x and y are in {code, id, name}
268-
- state_code -> hhs_region_number
268+
- state_code -> hhs
269269
270270
Parameters
271271
---------
@@ -274,7 +274,7 @@ def add_geocode(
274274
from_code: {'fips', 'zip', 'jhu_uid', 'state_code', 'state_id', 'state_name'}
275275
Specifies the geocode type of the data in from_col.
276276
new_code: {'fips', 'zip', 'state_code', 'state_id', 'state_name', 'hrr', 'msa',
277-
'hhs_region_number'}
277+
'hhs'}
278278
Specifies the geocode type in new_col.
279279
from_col: str, default None
280280
Name of the column in dataframe containing from_code. If None, then the name
@@ -364,7 +364,7 @@ def replace_geocode(
364364
- zip -> state_code, state_id, state_name, fips, msa, hrr, nation
365365
- jhu_uid -> fips
366366
- state_x -> state_y, where x and y are in {code, id, name}
367-
- state_code -> hhs_region_number
367+
- state_code -> hhs
368368
369369
Parameters
370370
---------
@@ -377,7 +377,7 @@ def replace_geocode(
377377
new_col: str
378378
Name of the new column to add to data.
379379
new_code: {'fips', 'zip', 'state_code', 'state_id', 'state_name', 'hrr', 'msa',
380-
'hhs_region_number'}
380+
'hhs'}
381381
Specifies the geocode type of the data in new_col.
382382
date_col: str or None, default "date"
383383
Specify which column contains the date values. Used for value aggregation.

_delphi_utils_python/tests/test_geomap.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_crosswalks(self):
137137
# assert cw.groupby("zip")["weight"].sum().round(5).eq(1.0).all()
138138
cw = gmpr._load_crosswalk(from_code="zip", to_code="state")
139139
assert cw.groupby("zip")["weight"].sum().round(5).eq(1.0).all()
140-
cw = gmpr._load_crosswalk(from_code="zip", to_code="hhs_region_number")
140+
cw = gmpr._load_crosswalk(from_code="zip", to_code="hhs")
141141
assert cw.groupby("zip")["weight"].sum().round(5).eq(1.0).all()
142142

143143

@@ -205,8 +205,8 @@ def test_add_geocode(self):
205205

206206
# state_code -> hhs
207207
new_data = gmpr.add_geocode(self.zip_data, "zip", "state_code")
208-
new_data2 = gmpr.add_geocode(new_data, "state_code", "hhs_region_number")
209-
assert new_data2["hhs_region_number"].unique().size == 2
208+
new_data2 = gmpr.add_geocode(new_data, "state_code", "hhs")
209+
assert new_data2["hhs"].unique().size == 2
210210

211211
# state_name -> state_id
212212
new_data = gmpr.replace_geocode(self.zip_data, "zip", "state_name")
@@ -267,26 +267,26 @@ def test_add_geocode(self):
267267

268268
# fips -> hhs
269269
new_data = gmpr.replace_geocode(self.fips_data_3.drop(columns=["date"]),
270-
"fips", "hhs_region_number", date_col=None)
270+
"fips", "hhs", date_col=None)
271271
assert new_data.equals(
272272
pd.DataFrame().from_dict(
273273
{
274-
"hhs_region_number": {0: "2", 1: "6"},
274+
"hhs": {0: "2", 1: "6"},
275275
"count": {0: 12, 1: 6},
276276
"total": {0: 111, 1: 13}
277277
}
278278
)
279279
)
280280

281281
# zip -> hhs
282-
new_data = gmpr.replace_geocode(self.zip_data, "zip", "hhs_region_number")
282+
new_data = gmpr.replace_geocode(self.zip_data, "zip", "hhs")
283283
new_data = new_data.round(10) # get rid of a floating point error with 99.00000000000001
284284
assert new_data.equals(
285285
pd.DataFrame().from_dict(
286286
{
287287
"date": {0: pd.Timestamp("2018-01-01"), 1: pd.Timestamp("2018-01-01"),
288288
2: pd.Timestamp("2018-01-03"), 3: pd.Timestamp("2018-01-03")},
289-
"hhs_region_number": {0: "5", 1: "9", 2: "5", 3: "9"},
289+
"hhs": {0: "5", 1: "9", 2: "5", 3: "9"},
290290
"count": {0: 99.0, 1: 801.0, 2: 100.0, 3: 786.0},
291291
"total": {0: 198.0, 1: 1602.0, 2: 200.0, 3: 1572.0}
292292
}

0 commit comments

Comments
 (0)