Skip to content

Fix linting for google symptoms #455

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 2 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion google_symptoms/delphi_google_symptoms/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
'Wisconsin': 'wi',
'Wyoming': 'wy'}

DC_FIPS = "11001"
DC_FIPS = "11001"
10 changes: 5 additions & 5 deletions google_symptoms/delphi_google_symptoms/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def generate_transition_matrix(geo_res):
The first is a data frame for HRR regions and the second are MSA
regions.
"""
map_df = gmpr._load_crosswalk("fips", geo_res)
map_df = gmpr._load_crosswalk("fips", geo_res) # pylint: disable=W0212
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this one is fine; google_symptoms is deprecated anyway)

# Add population as weights
map_df = gmpr.add_population_column(map_df, "fips")
if geo_res == "hrr":
Expand All @@ -31,7 +31,7 @@ def generate_transition_matrix(geo_res):
msa_pop, on=geo_res, how="inner", suffixes=["_raw", "_groupsum"]
)
map_df["weight"] = map_df["population_raw"] / map_df["population_groupsum"]

map_df = pd.pivot_table(
map_df, values='weight', index=["fips"], columns=[geo_res]
).fillna(0).reset_index().rename({"fips": "geo_id"}, axis = 1)
Expand All @@ -52,13 +52,13 @@ def geo_map(df, geo_res):
Returns
-------
pd.DataFrame
A dataframe with columns "geo_id", "timestamp",
and columns for signal vals.
A dataframe with columns "geo_id", "timestamp",
and columns for signal vals.
The geo_id has been converted from fips to HRRs/MSAs
"""
if geo_res in set(["county", "state"]):
return df

map_df = generate_transition_matrix(geo_res)
converted_df = pd.DataFrame(columns = df.columns)
for _date in df["timestamp"].unique():
Expand Down
4 changes: 2 additions & 2 deletions google_symptoms/delphi_google_symptoms/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def preprocess(df, level):
"""
# Constants
KEEP_COLUMNS = ["geo_id", "date"] + METRICS + ["combined_symptoms"]

df["combined_symptoms"] = 0
for metric in METRICS:
df.rename({"symptom:" + metric: metric}, axis = 1, inplace = True)
Expand All @@ -52,7 +52,7 @@ def preprocess(df, level):
(df["Anosmia"].isnull())
& (df["Ageusia"].isnull())
, "combined_symptoms"] = np.nan

# Delete rows with missing FIPS
null_mask = (df["geo_id"].isnull())
df = df.loc[~null_mask]
Expand Down
4 changes: 2 additions & 2 deletions google_symptoms/delphi_google_symptoms/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run_module():
base_url = params["base_url"]

# Pull GS data
dfs = pull_gs_data(base_url)
dfs = pull_gs_data(base_url)
for geo_res in GEO_RESOLUTIONS:
if geo_res == "state":
df_pull = dfs["state"]
Expand All @@ -48,4 +48,4 @@ def run_module():
start_date=SMOOTHERS_MAP[smoother][1](export_start_date),
metric=metric.lower(),
geo_res=geo_res,
sensor=sensor_name)
sensor=sensor_name)