Skip to content

Commit 473ef27

Browse files
authored
Merge pull request #615 from cmu-delphi/safegraph-pattens-hhrnation
Add nation and HHS to Safegraph patterns
2 parents f00bb5d + f404bd2 commit 473ef27

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

safegraph_patterns/DETAILS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
We import Zip Code-level raw mobility indicators from SafeGraph **Weekly
44
Patterns** dataset, calculate functions of the raw data, and then aggregate
5-
he data to the county, hrr, msa and state levels.
5+
he data to the county, hrr, msa, hhs, nation, and state levels.
66

77
## Brand Information
88
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
2222
* `msa`: reported using CBSA (consistent with all other COVIDcast sensors)
2323
* `hrr`: reported using HRR number (consistent with all other COVIDcast sensors)
2424
* `state`: reported using two-letter postal code
25+
* `hhs`: reported using HHS region number
26+
* `nation`: reported using two-letter country abbreviation. Just `us` for now.
2527

2628
## Metrics, Level 1 (`m1`)
2729
* `bars_visit`: The number of visits to bars(places with NAICS code = 722410)

safegraph_patterns/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
We import raw mobility data from Safegraph Weekly Patterns, calculate some
44
statistics upon it, and aggregate the data from the Zip Code level to County,
5-
HRR, MSA and State levels. For detailed information see the files `DETAILS.md`
5+
HRR, MSA, HHS, Nation, and State levels. For detailed information see the files `DETAILS.md`
66
contained in this directory.
77

88
## Running the Indicator

safegraph_patterns/delphi_safegraph_patterns/process.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"county": "fips",
1515
"msa": "msa",
1616
"hrr": "hrr",
17-
"state": "state_id"
17+
"state": "state_id",
18+
"hhs": "hhs",
19+
"nation": "nation"
1820
}
1921

2022
def construct_signals(df, metric_names, naics_codes, brand_df):
@@ -97,7 +99,7 @@ def aggregate(df, metric, geo_res):
9799
metric: str
98100
Name of metric to be exported.
99101
geo_resolution: str
100-
One of ('county', 'hrr, 'msa', 'state')
102+
One of ('county', 'hrr, 'msa', 'state', 'hhs', 'nation')
101103
102104
Returns
103105
-------
@@ -112,9 +114,7 @@ def aggregate(df, metric, geo_res):
112114
gmpr = GeoMapper()
113115
geo_key = GEO_KEY_DICT[geo_res]
114116
df = gmpr.add_population_column(df, "zip")
115-
df = gmpr.replace_geocode(df, "zip", geo_key,
116-
date_col="timestamp",
117-
data_cols=[metric_count_name, "population"])
117+
df = gmpr.replace_geocode(df, "zip", geo_key, date_col="timestamp", data_cols=[metric_count_name, "population"])
118118

119119
df[metric_prop_name] = df[metric_count_name] / df["population"] \
120120
* INCIDENCE_BASE

safegraph_patterns/delphi_safegraph_patterns/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"hrr",
3636
"msa",
3737
"state",
38+
"hhs",
39+
"nation"
3840
]
3941

4042

0 commit comments

Comments
 (0)