From 91939085b0330eabb9ac18e3105a0644af2c133f Mon Sep 17 00:00:00 2001 From: Brian Clark Date: Thu, 20 Aug 2020 10:02:32 -0400 Subject: [PATCH 1/9] Add missing whitespace --- jhu/delphi_jhu/geo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhu/delphi_jhu/geo.py b/jhu/delphi_jhu/geo.py index 950a75faf..1502c2c91 100644 --- a/jhu/delphi_jhu/geo.py +++ b/jhu/delphi_jhu/geo.py @@ -37,7 +37,7 @@ def geo_map(df: pd.DataFrame, geo_res: str, sensor: str): elif geo_res == "msa": df = gmpr.county_to_msa(df, fips_col="fips", msa_col="geo_id", date_col="timestamp") df['geo_id'] = df['geo_id'].astype(int) - print(df[df['population']==0]) + print(df[df['population'] == 0]) elif geo_res == 'hrr': df = gmpr.county_to_hrr(df, fips_col="fips", hrr_col="geo_id", date_col="timestamp") df['geo_id'] = df['geo_id'].astype(int) From b6d838a30d9f7de4ade2c68927d8958bae9c02b0 Mon Sep 17 00:00:00 2001 From: Brian Clark Date: Thu, 20 Aug 2020 10:10:06 -0400 Subject: [PATCH 2/9] Remove trailing newlines --- jhu/delphi_jhu/geo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jhu/delphi_jhu/geo.py b/jhu/delphi_jhu/geo.py index 1502c2c91..67d8f866e 100644 --- a/jhu/delphi_jhu/geo.py +++ b/jhu/delphi_jhu/geo.py @@ -48,5 +48,3 @@ def geo_map(df: pd.DataFrame, geo_res: str, sensor: str): df['new_counts'] = df['new_counts'] df['cumulative_counts'] = df['cumulative_counts'] return df - - From 522df628ba36f1313430e45e302ce6298f6e2a48 Mon Sep 17 00:00:00 2001 From: Brian Clark Date: Thu, 20 Aug 2020 10:12:57 -0400 Subject: [PATCH 3/9] Add spaces after commas --- jhu/delphi_jhu/pull.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhu/delphi_jhu/pull.py b/jhu/delphi_jhu/pull.py index 96a32937f..0334bdac8 100644 --- a/jhu/delphi_jhu/pull.py +++ b/jhu/delphi_jhu/pull.py @@ -72,7 +72,7 @@ def pull_jhu_data(base_url: str, metric: str, pop_df: pd.DataFrame) -> pd.DataFr gmpr = GeoMapper() - df = gmpr.jhu_uid_to_county(df,jhu_col="UID",date_col='timestamp') + df = gmpr.jhu_uid_to_county(df, jhu_col="UID", date_col='timestamp') """ df = df[ From 05b9b0deb6e0a662982f5c5d3ffd905307514b5f Mon Sep 17 00:00:00 2001 From: Brian Clark Date: Thu, 20 Aug 2020 10:19:20 -0400 Subject: [PATCH 4/9] Add space after comma --- jhu/delphi_jhu/pull.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhu/delphi_jhu/pull.py b/jhu/delphi_jhu/pull.py index 0334bdac8..e21e88fb3 100644 --- a/jhu/delphi_jhu/pull.py +++ b/jhu/delphi_jhu/pull.py @@ -87,7 +87,7 @@ def pull_jhu_data(base_url: str, metric: str, pop_df: pd.DataFrame) -> pd.DataFr """ # Merge in population LOWERCASE, consistent across confirmed and deaths # Set population as NAN for fake fips - pop_df.rename(columns={'FIPS':'fips'},inplace=True) + pop_df.rename(columns={'FIPS':'fips'}, inplace=True) pop_df['fips'] = pop_df['fips'].astype(int).\ astype(str).str.zfill(5) df = pd.merge(df, pop_df, on="fips", how='left') From 5906ce2ed276dc33a22baac13c7b67ca805b29b6 Mon Sep 17 00:00:00 2001 From: Brian Clark Date: Thu, 20 Aug 2020 10:24:11 -0400 Subject: [PATCH 5/9] Fix import order --- jhu/delphi_jhu/pull.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhu/delphi_jhu/pull.py b/jhu/delphi_jhu/pull.py index e21e88fb3..295159f8b 100644 --- a/jhu/delphi_jhu/pull.py +++ b/jhu/delphi_jhu/pull.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- +import re from delphi_utils import GeoMapper import pandas as pd import numpy as np -import re def detect_date_col(col_name: str): """determine if column name is a date""" From 085ffed6e19d7abc004f9348815f84792503e826 Mon Sep 17 00:00:00 2001 From: Vishakha <59063647+vishakha1812@users.noreply.github.com> Date: Thu, 20 Aug 2020 12:49:32 -0700 Subject: [PATCH 6/9] Added missing prefix r --- jhu/delphi_jhu/geo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhu/delphi_jhu/geo.py b/jhu/delphi_jhu/geo.py index 67d8f866e..442c75731 100644 --- a/jhu/delphi_jhu/geo.py +++ b/jhu/delphi_jhu/geo.py @@ -4,7 +4,7 @@ INCIDENCE_BASE = 100000 -def geo_map(df: pd.DataFrame, geo_res: str, sensor: str): +def geo_map(df: pd.DataFrame, geo_res: str): """ Maps a DataFrame df, which contains data at the county resolution, and aggregate it to the geographic resolution geo_res. From b11a8cbad00209fbe0d7305481af39a8811fcc2c Mon Sep 17 00:00:00 2001 From: Vishakha <59063647+vishakha1812@users.noreply.github.com> Date: Thu, 20 Aug 2020 13:00:15 -0700 Subject: [PATCH 7/9] Added missing prefix r --- jhu/delphi_jhu/pull.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/jhu/delphi_jhu/pull.py b/jhu/delphi_jhu/pull.py index 295159f8b..4ddc18652 100644 --- a/jhu/delphi_jhu/pull.py +++ b/jhu/delphi_jhu/pull.py @@ -7,7 +7,7 @@ def detect_date_col(col_name: str): """determine if column name is a date""" - date_match = re.match('\d{1,2}\/\d{1,2}\/\d{1,2}', col_name) + date_match = re.match(r'\d{1,2}\/\d{1,2}\/\d{1,2}', col_name) if date_match: return True return False @@ -51,9 +51,6 @@ def pull_jhu_data(base_url: str, metric: str, pop_df: pd.DataFrame) -> pd.DataFr pd.DataFrame Dataframe as described above. """ - # Two metrics, two schema... - MIN_FIPS = 1000 - MAX_FIPS = 73000 # Read data df = pd.read_csv(base_url.format(metric=metric)) @@ -70,7 +67,6 @@ def pull_jhu_data(base_url: str, metric: str, pop_df: pd.DataFrame) -> pd.DataFr ) df["timestamp"] = pd.to_datetime(df["timestamp"]) - gmpr = GeoMapper() df = gmpr.jhu_uid_to_county(df, jhu_col="UID", date_col='timestamp') @@ -87,8 +83,8 @@ def pull_jhu_data(base_url: str, metric: str, pop_df: pd.DataFrame) -> pd.DataFr """ # Merge in population LOWERCASE, consistent across confirmed and deaths # Set population as NAN for fake fips - pop_df.rename(columns={'FIPS':'fips'}, inplace=True) - pop_df['fips'] = pop_df['fips'].astype(int).\ + pop_df.rename(columns={'FIPS': 'fips'}, inplace=True) + pop_df['fips'] = pop_df['fips'].astype(int). \ astype(str).str.zfill(5) df = pd.merge(df, pop_df, on="fips", how='left') From 2d61a87628db6e2de55acf7b77da57ad33edafd7 Mon Sep 17 00:00:00 2001 From: Vishakha <59063647+vishakha1812@users.noreply.github.com> Date: Thu, 20 Aug 2020 21:02:39 -0700 Subject: [PATCH 8/9] Removed unused stmt. and corrected import order --- jhu/delphi_jhu/pull.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/jhu/delphi_jhu/pull.py b/jhu/delphi_jhu/pull.py index f10057f9d..748a0b910 100644 --- a/jhu/delphi_jhu/pull.py +++ b/jhu/delphi_jhu/pull.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import re -from delphi_utils import GeoMapper import pandas as pd import numpy as np +from delphi_utils import GeoMapper def detect_date_col(col_name: str): """determine if column name is a date""" @@ -70,17 +70,6 @@ def pull_jhu_data(base_url: str, metric: str, pop_df: pd.DataFrame) -> pd.DataFr gmpr = GeoMapper() df = gmpr.jhu_uid_to_county(df, jhu_col="UID", date_col='timestamp') - """ - df = df[ - ( - (fips_int >= MIN_FIPS) # US non-state territories - & (fips_int < MAX_FIPS) - ) # "Uncategorized", etc. - # Get Fake FIPS for unassigned cases - | np.logical_and(fips_int >= 90001, - fips_int <= 90056) - ] - """ # Merge in population LOWERCASE, consistent across confirmed and deaths # Set population as NAN for fake fips pop_df.rename(columns={'FIPS':'fips'}, inplace=True) From 3c15428f4ff10b43c979d9303b5008aebf2fc81e Mon Sep 17 00:00:00 2001 From: Vishakha <59063647+vishakha1812@users.noreply.github.com> Date: Thu, 20 Aug 2020 21:03:04 -0700 Subject: [PATCH 9/9] Removed unused argument --- jhu/delphi_jhu/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhu/delphi_jhu/run.py b/jhu/delphi_jhu/run.py index 093f19928..ac06304ad 100644 --- a/jhu/delphi_jhu/run.py +++ b/jhu/delphi_jhu/run.py @@ -92,7 +92,7 @@ def run_module(): print(metric, geo_res, sensor, smoother) df = dfs[metric] # Aggregate to appropriate geographic resolution - df = geo_map(df, geo_res, sensor) + df = geo_map(df, geo_res) df["val"] = SMOOTHERS_MAP[smoother][0](df[sensor].values) df["se"] = np.nan df["sample_size"] = np.nan