bucky.data.timeseries#

Objects that hold timeseries objects defined over multiple locations.

Module Contents#

Classes#

BuckyFittedCaseData

Dataclass that holds the fitted CSSE case/death data, including incidence rates.

BuckyFittedData

Dataclass for fitted case/death time series data.

CSSEData

Dataclass that holds the CSSE case/death data.

HHSData

Dataclass that holds the HHS hospitalization data.

SpatialStratifiedTimeseries

Class representing a generic timeseries that is defined over admin regions.

Functions#

_mask_date_range(dates: numpy.ndarray, n_days: Optional[int] = None, valid_date_range: Tuple[Optional[datetime.date], Optional[datetime.date]] = (None, None), force_enddate: Optional[datetime.date] = None, force_enddate_dow: Optional[int] = None)

Calculate the bool mask for dates to include from the historical data.

class bucky.data.timeseries.BuckyFittedCaseData[source]#

Bases: SpatialStratifiedTimeseries

Dataclass that holds the fitted CSSE case/death data, including incidence rates.

cumulative_cases :bucky._typing.ArrayLike#
cumulative_deaths :bucky._typing.ArrayLike#
incident_cases :bucky._typing.ArrayLike#
incident_deaths :bucky._typing.ArrayLike#
static from_csv(file: bucky._typing.PathLike, n_days: Optional[int] = None, valid_date_range=(None, None), force_enddate: Optional[datetime.date] = None, force_enddate_dow: Optional[int] = None, adm_mapping: Optional[bucky.data.adm_mapping.AdminLevelMapping] = None)[source]#

Read fitted CSSE data from CSV.

class bucky.data.timeseries.BuckyFittedData[source]#

Bases: SpatialStratifiedTimeseries

Dataclass for fitted case/death time series data.

cumulative_cases :bucky._typing.ArrayLike#
cumulative_deaths :bucky._typing.ArrayLike#
incident_cases :bucky._typing.ArrayLike#
incident_deaths :bucky._typing.ArrayLike#
class bucky.data.timeseries.CSSEData[source]#

Bases: SpatialStratifiedTimeseries

Dataclass that holds the CSSE case/death data.

cumulative_cases :bucky._typing.ArrayLike#
cumulative_deaths :bucky._typing.ArrayLike#
incident_cases :bucky._typing.ArrayLike#
incident_deaths :bucky._typing.ArrayLike#
__post_init__(self)[source]#

Fill in incidence data if only inited with cumulatives.

static from_csv(file: bucky._typing.PathLike, n_days: Optional[int] = None, valid_date_range=(None, None), force_enddate: Optional[datetime.date] = None, force_enddate_dow: Optional[int] = None, adm_mapping: Optional[bucky.data.adm_mapping.AdminLevelMapping] = None)[source]#

Read CSSE data from a CSV.

class bucky.data.timeseries.HHSData[source]#

Bases: SpatialStratifiedTimeseries

Dataclass that holds the HHS hospitalization data.

current_hospitalizations :bucky._typing.ArrayLike#
incident_hospitalizations :bucky._typing.ArrayLike#
static from_csv(file: bucky._typing.PathLike, n_days: Optional[int] = None, valid_date_range=(None, None), force_enddate: Optional[datetime.date] = None, force_enddate_dow: Optional[int] = None, adm_mapping: Optional[bucky.data.adm_mapping.AdminLevelMapping] = None)[source]#

Read HHS data from a CSV.

class bucky.data.timeseries.SpatialStratifiedTimeseries[source]#

Class representing a generic timeseries that is defined over admin regions.

adm_ids :bucky._typing.ArrayLike#
adm_level :int#
adm_mapping :bucky.data.adm_mapping.AdminLevelMapping#
dates :bucky._typing.ArrayLike#
__post_init__(self)[source]#

Perform some simple shape validation on after initing.

__repr__(self) str[source]#

Only print summary of the object in interactive sessions.

static _generic_from_csv(filename: bucky._typing.PathLike, n_days: Optional[int] = None, valid_date_range=(None, None), force_enddate: Optional[datetime.date] = None, force_enddate_dow: Optional[int] = None, adm_col: str = 'adm2', date_col: str = 'date', column_names: Dict[str, str] = None)[source]#

Return a dict containing args to a subclass’s constructor

property end_date(self) datetime.date#

The last date of valid data.

property n_days(self) int#

Total number of days of data.

property n_loc(self) int#

Total number of locations for which we have timeseries at the base admin level.

replace(self, **changes)[source]#

Replace data columns.

property start_date(self) datetime.date#

The first date of valid data.

sum_adm_level(self, level: Union[int, str])[source]#

Sum the values to a different admin level then they are defined on.

to_csv(self, filename, level=None)[source]#

Save the timeseries data to a csv.

to_dataframe(self, level=None)[source]#

Return the timeseries as a pandas.DataFrame.

to_dict(self, level=None)[source]#

Return the timeseries as a dict containing the data it’s indices.

validate_isfinite(self)[source]#

Check that there are no invalid values in the timeseries (nan, inf, etc).

bucky.data.timeseries._mask_date_range(dates: numpy.ndarray, n_days: Optional[int] = None, valid_date_range: Tuple[Optional[datetime.date], Optional[datetime.date]] = (None, None), force_enddate: Optional[datetime.date] = None, force_enddate_dow: Optional[int] = None)[source]#

Calculate the bool mask for dates to include from the historical data.