Skip to content

Commit f20cab9

Browse files
committed
add cleaning line
1 parent f35df7d commit f20cab9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

usafacts/delphi_usafacts/pull.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def pull_usafacts_data(base_url: str, metric: str, geo_mapper: GeoMapper) -> pd.
5555
"""
5656
# Read data
5757
df = pd.read_csv(base_url.format(metric=metric)).rename({"countyFIPS":"FIPS"}, axis=1)
58+
59+
# Clean commas in count fields in case the input file included them
60+
df[df.columns[4:]] = df[df.columns[4:]].applymap(
61+
lambda x: int(x.replace(",", "")) if isinstance(x, str) else x)
62+
5863
# Check missing FIPS
5964
null_mask = pd.isnull(df["FIPS"])
6065
assert null_mask.sum() == 0

0 commit comments

Comments
 (0)