From cfc524a15c4cb48d19d4f4bfd8e8553013cd091c Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 9 Dec 2020 01:35:52 -0800 Subject: [PATCH 1/2] add hhs and nation --- safegraph_patterns/DETAILS.md | 4 +++- safegraph_patterns/README.md | 2 +- .../delphi_safegraph_patterns/process.py | 11 ++++++----- safegraph_patterns/delphi_safegraph_patterns/run.py | 2 ++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/safegraph_patterns/DETAILS.md b/safegraph_patterns/DETAILS.md index ec2048b8e..8261426a9 100644 --- a/safegraph_patterns/DETAILS.md +++ b/safegraph_patterns/DETAILS.md @@ -2,7 +2,7 @@ We import Zip Code-level raw mobility indicators from SafeGraph **Weekly Patterns** dataset, calculate functions of the raw data, and then aggregate -he data to the county, hrr, msa and state levels. +he data to the county, hrr, msa, hhs, nation, and state levels. ## Brand Information SafeGraph provides daily number of visits to points of interest (POIs) in Weekly @@ -22,6 +22,8 @@ new necessary `brand_info.csv` in `./statics` with suffix YYYYMM(release version * `msa`: reported using CBSA (consistent with all other COVIDcast sensors) * `hrr`: reported using HRR number (consistent with all other COVIDcast sensors) * `state`: reported using two-letter postal code +* `hhs`: reported using HHS region number +* `nation`: reported using two-letter country abbreviation. Just `us` for now. ## Metrics, Level 1 (`m1`) * `bars_visit`: The number of visits to bars(places with NAICS code = 722410) diff --git a/safegraph_patterns/README.md b/safegraph_patterns/README.md index eb9651eb8..b94b87e87 100644 --- a/safegraph_patterns/README.md +++ b/safegraph_patterns/README.md @@ -2,7 +2,7 @@ We import raw mobility data from Safegraph Weekly Patterns, calculate some statistics upon it, and aggregate the data from the Zip Code level to County, -HRR, MSA and State levels. For detailed information see the files `DETAILS.md` +HRR, MSA, HHS, Nation, and State levels. For detailed information see the files `DETAILS.md` contained in this directory. ## Running the Indicator diff --git a/safegraph_patterns/delphi_safegraph_patterns/process.py b/safegraph_patterns/delphi_safegraph_patterns/process.py index 4fd32faf7..573388285 100644 --- a/safegraph_patterns/delphi_safegraph_patterns/process.py +++ b/safegraph_patterns/delphi_safegraph_patterns/process.py @@ -14,7 +14,9 @@ "county": "fips", "msa": "msa", "hrr": "hrr", - "state": "state_id" + "state": "state_id", + "hhs": "hhs", + "nation": "nation" } def construct_signals(df, metric_names, naics_codes, brand_df): @@ -97,7 +99,7 @@ def aggregate(df, metric, geo_res): metric: str Name of metric to be exported. geo_resolution: str - One of ('county', 'hrr, 'msa', 'state') + One of ('county', 'hrr, 'msa', 'state', 'hhs', 'nation') Returns ------- @@ -112,9 +114,8 @@ def aggregate(df, metric, geo_res): gmpr = GeoMapper() geo_key = GEO_KEY_DICT[geo_res] df = gmpr.add_population_column(df, "zip") - df = gmpr.replace_geocode(df, "zip", geo_key, - date_col="timestamp", - data_cols=[metric_count_name, "population"]) + assert 0 + df = gmpr.replace_geocode(df, "zip", geo_key, date_col="timestamp", data_cols=[metric_count_name, "population"]) df[metric_prop_name] = df[metric_count_name] / df["population"] \ * INCIDENCE_BASE diff --git a/safegraph_patterns/delphi_safegraph_patterns/run.py b/safegraph_patterns/delphi_safegraph_patterns/run.py index 8744453be..0f024fda3 100644 --- a/safegraph_patterns/delphi_safegraph_patterns/run.py +++ b/safegraph_patterns/delphi_safegraph_patterns/run.py @@ -35,6 +35,8 @@ "hrr", "msa", "state", + "hhs", + "nation" ] From 5f39b8a7e1840cc36457fde3dde0835d9af5d7c2 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 9 Dec 2020 01:46:27 -0800 Subject: [PATCH 2/2] remove assert --- safegraph_patterns/delphi_safegraph_patterns/process.py | 1 - 1 file changed, 1 deletion(-) diff --git a/safegraph_patterns/delphi_safegraph_patterns/process.py b/safegraph_patterns/delphi_safegraph_patterns/process.py index 573388285..58d59fcbc 100644 --- a/safegraph_patterns/delphi_safegraph_patterns/process.py +++ b/safegraph_patterns/delphi_safegraph_patterns/process.py @@ -114,7 +114,6 @@ def aggregate(df, metric, geo_res): gmpr = GeoMapper() geo_key = GEO_KEY_DICT[geo_res] df = gmpr.add_population_column(df, "zip") - assert 0 df = gmpr.replace_geocode(df, "zip", geo_key, date_col="timestamp", data_cols=[metric_count_name, "population"]) df[metric_prop_name] = df[metric_count_name] / df["population"] \