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
4 changes: 3 additions & 1 deletion safegraph_patterns/DETAILS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion safegraph_patterns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions safegraph_patterns/delphi_safegraph_patterns/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
-------
Expand All @@ -112,9 +114,7 @@ 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"])
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
Expand Down
2 changes: 2 additions & 0 deletions safegraph_patterns/delphi_safegraph_patterns/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"hrr",
"msa",
"state",
"hhs",
"nation"
]


Expand Down