|
27 | 27 | ZIP_HSA_HRR_URL = "https://atlasdata.dartmouth.edu/downloads/geography/ZipHsaHrr18.csv.zip"
|
28 | 28 | ZIP_HSA_HRR_FILENAME = "ZipHsaHrr18.csv"
|
29 | 29 | FIPS_MSA_URL = "https://www2.census.gov/programs-surveys/metro-micro/geographies/reference-files/2018/delineation-files/list1_Sep_2018.xls"
|
30 |
| -JHU_FIPS_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv" |
31 | 30 | STATE_CODES_URL = "http://www2.census.gov/geo/docs/reference/state.txt?#"
|
32 | 31 | FIPS_POPULATION_URL = f"https://www2.census.gov/programs-surveys/popest/datasets/2010-{YEAR}/counties/totals/co-est{YEAR}-alldata.csv"
|
33 | 32 | FIPS_PUERTO_RICO_POPULATION_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?"
|
|
57 | 56 | STATE_POPULATION_OUT_FILENAME = "state_pop.csv"
|
58 | 57 | HHS_POPULATION_OUT_FILENAME = "hhs_pop.csv"
|
59 | 58 | NATION_POPULATION_OUT_FILENAME = "nation_pop.csv"
|
60 |
| -JHU_FIPS_OUT_FILENAME = "jhu_uid_fips_table.csv" |
61 | 59 |
|
62 | 60 |
|
63 | 61 | def create_fips_zip_crosswalk():
|
@@ -111,101 +109,6 @@ def create_fips_msa_crosswalk():
|
111 | 109 | msa_df.sort_values(["fips", "msa"]).to_csv(join(OUTPUT_DIR, FIPS_MSA_OUT_FILENAME), columns=["fips", "msa"], index=False)
|
112 | 110 |
|
113 | 111 |
|
114 |
| -def create_jhu_uid_fips_crosswalk(): |
115 |
| - """Build a crosswalk table from JHU UID to FIPS.""" |
116 |
| - # These are hand modifications that need to be made to the translation |
117 |
| - # between JHU UID and FIPS. See below for the special cases information |
118 |
| - # https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html#geographical-exceptions |
119 |
| - hand_additions = pd.DataFrame( |
120 |
| - [ |
121 |
| - { |
122 |
| - "jhu_uid": "84070002", |
123 |
| - "fips": "25007", # Split aggregation of Dukes and Nantucket, Massachusetts |
124 |
| - "weight": 16535 / (16535 + 10172), # Population: 16535 |
125 |
| - }, |
126 |
| - { |
127 |
| - "jhu_uid": "84070002", |
128 |
| - "fips": "25019", |
129 |
| - "weight": 10172 / (16535 + 10172), # Population: 10172 |
130 |
| - }, |
131 |
| - { |
132 |
| - "jhu_uid": "84070003", |
133 |
| - "fips": "29095", # Kansas City, Missouri |
134 |
| - "weight": 674158 / 1084897, # Population: 674158 |
135 |
| - }, |
136 |
| - { |
137 |
| - "jhu_uid": "84070003", |
138 |
| - "fips": "29165", |
139 |
| - "weight": 89322 / 1084897, # Population: 89322 |
140 |
| - }, |
141 |
| - { |
142 |
| - "jhu_uid": "84070003", |
143 |
| - "fips": "29037", |
144 |
| - "weight": 99478 / 1084897, # Population: 99478 |
145 |
| - }, |
146 |
| - { |
147 |
| - "jhu_uid": "84070003", |
148 |
| - "fips": "29047", |
149 |
| - "weight": 221939 / 1084897, # Population: 221939 |
150 |
| - }, |
151 |
| - # Kusilvak, Alaska |
152 |
| - {"jhu_uid": "84002158", "fips": "02270", "weight": 1.0}, |
153 |
| - # Oglala Lakota |
154 |
| - {"jhu_uid": "84046102", "fips": "46113", "weight": 1.0}, |
155 |
| - # Aggregate Utah territories into a "State FIPS" |
156 |
| - {"jhu_uid": "84070015", "fips": "49000", "weight": 1.0}, |
157 |
| - {"jhu_uid": "84070016", "fips": "49000", "weight": 1.0}, |
158 |
| - {"jhu_uid": "84070017", "fips": "49000", "weight": 1.0}, |
159 |
| - {"jhu_uid": "84070018", "fips": "49000", "weight": 1.0}, |
160 |
| - {"jhu_uid": "84070019", "fips": "49000", "weight": 1.0}, |
161 |
| - {"jhu_uid": "84070020", "fips": "49000", "weight": 1.0}, |
162 |
| - ] |
163 |
| - ) |
164 |
| - # Map the Unassigned category to a custom megaFIPS XX000 |
165 |
| - unassigned_states = pd.DataFrame( |
166 |
| - {"jhu_uid": str(x), "fips": str(x)[-2:].ljust(5, "0"), "weight": 1.0} |
167 |
| - for x in range(84090001, 84090057) |
168 |
| - ) |
169 |
| - # Map the Out of State category to a custom megaFIPS XX000 |
170 |
| - out_of_state = pd.DataFrame( |
171 |
| - {"jhu_uid": str(x), "fips": str(x)[-2:].ljust(5, "0"), "weight": 1.0} |
172 |
| - for x in range(84080001, 84080057) |
173 |
| - ) |
174 |
| - # Map the Unassigned and Out of State categories to the cusom megaFIPS 72000 |
175 |
| - puerto_rico_unassigned = pd.DataFrame( |
176 |
| - [ |
177 |
| - {"jhu_uid": "63072888", "fips": "72000", "weight": 1.0}, |
178 |
| - {"jhu_uid": "63072999", "fips": "72000", "weight": 1.0}, |
179 |
| - ] |
180 |
| - ) |
181 |
| - cruise_ships = pd.DataFrame( |
182 |
| - [ |
183 |
| - {"jhu_uid": "84088888", "fips": "88888", "weight": 1.0}, |
184 |
| - {"jhu_uid": "84099999", "fips": "99999", "weight": 1.0}, |
185 |
| - ] |
186 |
| - ) |
187 |
| - |
188 |
| - |
189 |
| - jhu_df = pd.read_csv(JHU_FIPS_URL, dtype={"UID": str, "FIPS": str}).query("Country_Region == 'US'") |
190 |
| - jhu_df = jhu_df.rename(columns={"UID": "jhu_uid", "FIPS": "fips"}).dropna(subset=["fips"]) |
191 |
| - |
192 |
| - # FIPS Codes that are just two digits long should be zero filled on the right. |
193 |
| - # These are US state codes (XX) and the territories Guam (66), Northern Mariana Islands (69), |
194 |
| - # Virgin Islands (78), and Puerto Rico (72). |
195 |
| - fips_territories = jhu_df["fips"].str.len() <= 2 |
196 |
| - jhu_df.loc[fips_territories, "fips"] = jhu_df.loc[fips_territories, "fips"].str.ljust(5, "0") |
197 |
| - |
198 |
| - # Drop the JHU UIDs that were hand-modified |
199 |
| - manual_correction_ids = pd.concat([hand_additions, unassigned_states, out_of_state, puerto_rico_unassigned, cruise_ships])["jhu_uid"] |
200 |
| - jhu_df.drop(jhu_df.index[jhu_df["jhu_uid"].isin(manual_correction_ids)], inplace=True) |
201 |
| - |
202 |
| - # Add weights of 1.0 to everything not in hand additions, then merge in hand-additions |
203 |
| - # Finally, zero fill FIPS |
204 |
| - jhu_df["weight"] = 1.0 |
205 |
| - jhu_df = pd.concat([jhu_df, hand_additions, unassigned_states, out_of_state, puerto_rico_unassigned]) |
206 |
| - jhu_df["fips"] = jhu_df["fips"].astype(int).astype(str).str.zfill(5) |
207 |
| - jhu_df.sort_values(["jhu_uid", "fips"]).to_csv(join(OUTPUT_DIR, JHU_FIPS_OUT_FILENAME), columns=["jhu_uid", "fips", "weight"], index=False) |
208 |
| - |
209 | 112 |
|
210 | 113 | def create_state_codes_crosswalk():
|
211 | 114 | """Build a State ID -> State Name -> State code crosswalk file."""
|
@@ -659,7 +562,6 @@ def clear_dir(dir_path: str):
|
659 | 562 | create_fips_zip_crosswalk()
|
660 | 563 | create_zip_hsa_hrr_crosswalk()
|
661 | 564 | create_fips_msa_crosswalk()
|
662 |
| - create_jhu_uid_fips_crosswalk() |
663 | 565 | create_state_codes_crosswalk()
|
664 | 566 | create_state_hhs_crosswalk()
|
665 | 567 | create_fips_population_table()
|
|
0 commit comments