diff --git a/google_symptoms/delphi_google_symptoms/constants.py b/google_symptoms/delphi_google_symptoms/constants.py index 06f9187d8..0173b7d40 100644 --- a/google_symptoms/delphi_google_symptoms/constants.py +++ b/google_symptoms/delphi_google_symptoms/constants.py @@ -80,4 +80,4 @@ 'Wisconsin': 'wi', 'Wyoming': 'wy'} -DC_FIPS = "11001" \ No newline at end of file +DC_FIPS = "11001" diff --git a/google_symptoms/delphi_google_symptoms/geo.py b/google_symptoms/delphi_google_symptoms/geo.py index 257ff884f..99bba48ec 100644 --- a/google_symptoms/delphi_google_symptoms/geo.py +++ b/google_symptoms/delphi_google_symptoms/geo.py @@ -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=protected-access # Add population as weights map_df = gmpr.add_population_column(map_df, "fips") if geo_res == "hrr": @@ -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) @@ -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(): @@ -75,4 +75,4 @@ def geo_map(df, geo_res): newdf[mask] = np.nan converted_df = converted_df.append(newdf) return converted_df - \ No newline at end of file + diff --git a/google_symptoms/delphi_google_symptoms/pull.py b/google_symptoms/delphi_google_symptoms/pull.py index 85aacf194..10b540c88 100644 --- a/google_symptoms/delphi_google_symptoms/pull.py +++ b/google_symptoms/delphi_google_symptoms/pull.py @@ -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) @@ -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] diff --git a/google_symptoms/delphi_google_symptoms/run.py b/google_symptoms/delphi_google_symptoms/run.py index 9634c80c7..170816c9a 100644 --- a/google_symptoms/delphi_google_symptoms/run.py +++ b/google_symptoms/delphi_google_symptoms/run.py @@ -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"] @@ -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) \ No newline at end of file + sensor=sensor_name)