Skip to content

Remove extraneous functions and calls from usafacts #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions usafacts/delphi_usafacts/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,12 @@
]


FIPS_TO_STATE = {v: k.lower() for k, v in STATE_TO_FIPS.items()}

# Valid geographical resolutions output by this indicator.
VALID_GEO_RES = ("county", "state", "msa", "hrr")
# Sensors that report proportions. For geo resolutions with unallocated cases
# or deaths, we avoid reporting these sensors.
PROP_SENSORS = ("incidence", "cumulative_prop")

def fips_to_state(fips: str) -> str:
"""Wrapper that handles exceptions to the FIPS scheme in the USAFacts data.

All the county FIPS codes are mapped to state by taking the first two
digits of the five digit, zero-padded county FIPS and applying
FIPS_TO_STATE to map it to the two-letter postal abbreviation.

Parameters
----------
fips: str
Five digit, zero padded county FIPS code

Returns
-------
str
Two-letter postal abbreviation, lower case.

Raises
------
KeyError
Inputted FIPS code not recognized.
"""
return FIPS_TO_STATE[fips[:2]]

def disburse(df: pd.DataFrame, pooled_fips: str, fips_list: list):
"""Disburse counts from POOLED_FIPS equally to the counties in FIPS_LIST.
Expand Down
4 changes: 0 additions & 4 deletions usafacts/delphi_usafacts/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ def pull_usafacts_data(base_url: str, metric: str, geo_mapper: GeoMapper) -> pd.
& (df["FIPS"] != 2270)
]

# Merge in population LOWERCASE, consistent across confirmed and deaths
# Population for unassigned cases/deaths is NAN
df = df.merge(pop_df, on="FIPS", how="left")

# Change FIPS from 0 to XX000 for statewise unallocated cases/deaths
unassigned_index = (df['FIPS'] == 0)
df.loc[unassigned_index, "FIPS"] = df["stateFIPS"].loc[unassigned_index].values * 1000
Expand Down