bucky.make_input_graph

Makes input graphs for the model using case, demographic, and mobility data.

Module Contents

Functions

compute_population_density(age_df, shape_df)

Computes normalized population density.

get_case_history(historical_data, end_date, num_days=DAYS_OF_HIST)

Gets case and death history for the requested number of days for each FIPS.

get_lex(last_requested_date, window_size=7)

Reads county-level location exposure indices from PlaceIQ location data and applies a window.

get_mobility_data(pop_density, end_date, county_df)

Fetches mobility data.

get_safegraph(last_requested_date, window_size=7)

Reads SafeGraph mobility data and applies a window.

read_descartes_data(end_date)

Reads Descartes mobility data [WS20].

read_lex_data(date)

Reads county-level location exposure indices for a given date from PlaceIQ location data.

bucky.make_input_graph.DAYS_OF_HIST = 100[source]
bucky.make_input_graph.args[source]
bucky.make_input_graph.parser[source]
bucky.make_input_graph.compute_population_density(age_df, shape_df)[source]

Computes normalized population density.

Parameters
Returns

pop_density – pandas.DataFrame with population density by FIPS

Return type

pandas.DataFrame

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, FIPS

  • end_date (str) – Last date to get data for

  • num_days (int) – Number of days of history requested

Returns

hist – Dictionary of case data, keyed by FIPS

Return type

dict

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
  • last_requested_date (str) – Fetches data for requested date

  • window_size (int, optional) – Size of window, in days, to apply to data

Returns

frac_df – TODO

Return type

pandas.DataFrame

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 FIPS

  • end_date (str) – Last date of historical data

  • county_df (pandas.DataFrame) – County-level shape data

Returns

bucky.make_input_graph.get_safegraph(last_requested_date, window_size=7)[source]

Reads SafeGraph mobility data and applies a window.

Parameters
  • last_requested_date (str) – Fetches data for requested date

  • window_size (int, optional) – Size of window, in days, to apply to data

Returns

frac_df – TODO

Return type

pandas.DataFrame

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

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

pandas.DataFrame