bucky.make_input_graph
¶
Makes input graphs for the model using case, demographic, and mobility data.
Module Contents¶
Functions¶
|
Computes normalized population density. |
|
Gets case and death history for the requested number of days for each FIPS. |
|
Reads county-level location exposure indices from PlaceIQ location data and applies a window. |
|
Fetches mobility data. |
|
Reads SafeGraph mobility data and applies a window. |
|
Reads Descartes mobility data [WS20]. |
|
Reads county-level location exposure indices for a given date from PlaceIQ location data. |
Attributes¶
- bucky.make_input_graph.DAYS_OF_HIST = 100¶
- bucky.make_input_graph.args¶
- bucky.make_input_graph.compute_population_density(age_df, shape_df)[source]¶
Computes normalized population density.
- Parameters
age_df (
pandas.DataFrame
) – age-stratified population datashape_df (
geopandas.GeoDataFrame
) – GeoDataFrame with shape information indexed by FIPS
- Returns
pop_density – pandas.DataFrame with population density by FIPS
- Return type
- bucky.make_input_graph.get_case_history(historical_data, end_date, num_days=DAYS_OF_HIST)[source]¶
Gets case and death history for the requested number of days for each FIPS.
If data is missing for a date, it is replaced with the data from the last valid date.
- Parameters
historical_data (
pandas.DataFrame
) – Dataframe with case, death data indexed by date, FIPSend_date (
str
) – Last date to get data fornum_days (
int
) – Number of days of history requested
- Returns
hist – Dictionary of case data, keyed by FIPS
- Return type
- bucky.make_input_graph.get_lex(last_requested_date, window_size=7)[source]¶
Reads county-level location exposure indices from PlaceIQ location data and applies a window.
- Parameters
- Returns
frac_df – TODO
- Return type
- bucky.make_input_graph.get_mobility_data(pop_density, end_date, county_df)[source]¶
Fetches mobility data.
- Parameters
pop_density (
pandas.DataFrame
) – Population density indexed by FIPSend_date (
str
) – Last date of historical datacounty_df (
pandas.DataFrame
) – County-level shape data
- Returns
edge_weights (
pandas.DataFrame
) – TODOmovement_dict (
dict
) – TODO
- bucky.make_input_graph.get_safegraph(last_requested_date, window_size=7)[source]¶
Reads SafeGraph mobility data and applies a window.
- Parameters
- Returns
frac_df – TODO
- Return type
- bucky.make_input_graph.read_descartes_data(end_date)[source]¶
Reads Descartes mobility data [WS20].
- Parameters
end_date (
str
) – Last date to get Descartes data- Returns
nat_frac_move (
pandas.DataFrame
) – TODOdl_state (
pandas.DataFrame
) – TODOdl_county (
pandas.DataFrame
) – TODO
Notes
Data provided by Descartes Labs (https://descarteslabs.com/mobility/) 1
- 1
Warren, Michael S. & Skillman, Samuel W. “Mobility Changes in Response to COVID-19”. arXiv:2003.14228 [cs.SI], Mar. 2020. arxiv.org/abs/2003.14228
- bucky.make_input_graph.read_lex_data(date)[source]¶
Reads county-level location exposure indices for a given date from PlaceIQ location data.
In order to improve performance, preprocessed data is saved. If the user requests data for a date that has already been preprocessed, it will read the data from disk instead of repeating the processing.
- Parameters
date (
str
) – Fetches data for requested date- Returns
df_long – Preprocessed LEX data
- Return type