zipcode-features 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zipcode_features/__init__.py +3 -2
- zipcode_features/data/cbsa_codes.json +935 -268
- zipcode_features/data/cbsa_to_zip.csv +47860 -0
- {zipcode_features-0.1.4.dist-info → zipcode_features-0.1.6.dist-info}/METADATA +1 -1
- {zipcode_features-0.1.4.dist-info → zipcode_features-0.1.6.dist-info}/RECORD +7 -6
- {zipcode_features-0.1.4.dist-info → zipcode_features-0.1.6.dist-info}/WHEEL +0 -0
- {zipcode_features-0.1.4.dist-info → zipcode_features-0.1.6.dist-info}/licenses/LICENSE +0 -0
zipcode_features/__init__.py
CHANGED
|
@@ -165,9 +165,10 @@ def _get_zip_to_cbsa_code() -> dict:
|
|
|
165
165
|
mapping is of the form:
|
|
166
166
|
{"zip code": "cbsa code"}
|
|
167
167
|
"""
|
|
168
|
-
with resources.path("zipcode_features.data", "
|
|
168
|
+
with resources.path("zipcode_features.data", "cbsa_to_zip.csv") as csv_path:
|
|
169
169
|
df = pd.read_csv(csv_path, dtype={'ZIP': str, "CBSA": str})
|
|
170
170
|
df = correct_code(df, "ZIP")
|
|
171
|
+
df = correct_code(df, "CBSA")
|
|
171
172
|
mapping = df.set_index('ZIP')['CBSA'].to_dict()
|
|
172
173
|
return partial(map_zip_to_cbsa, mapping)
|
|
173
174
|
|
|
@@ -187,7 +188,7 @@ def _get_cbsa_code_to_cbsa_name() -> dict:
|
|
|
187
188
|
df = pd.DataFrame(columns=["code", "name"])
|
|
188
189
|
df["name"] = code_to_name.values()
|
|
189
190
|
df["code"] = code_to_name.keys()
|
|
190
|
-
df["name"] = df["name"].str.replace(" -", "-")
|
|
191
|
+
df["name"] = df["name"].str.replace(" -", "-").replace("- ", "-")
|
|
191
192
|
df["name"] = df["name"].str.split().str.join(' ')
|
|
192
193
|
code_to_name = df.set_index('code')['name'].to_dict()
|
|
193
194
|
return partial(map_cbsa_code_to_name, code_to_name)
|