Skip to content
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
2 changes: 1 addition & 1 deletion jhu/delphi_jhu/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 2 additions & 17 deletions jhu/delphi_jhu/pull.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- 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"""
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
Expand Down Expand Up @@ -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))
Expand All @@ -70,21 +67,9 @@ 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')

"""
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)
Expand Down
2 changes: 1 addition & 1 deletion jhu/delphi_jhu/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down