pytorch_forecasting.data.timeseries._timeseries_v2.TimeSeries#
- class pytorch_forecasting.data.timeseries._timeseries_v2.TimeSeries(data: DataFrame, data_future: DataFrame | None = None, time: str | None = None, target: str | list[str] | None = None, group: list[str] | None = None, weight: str | None = None, num: list[str | list[str]] | None = None, cat: list[str | list[str]] | None = None, known: list[str | list[str]] | None = None, unknown: list[str | list[str]] | None = None, static: list[str | list[str]] | None = None)[source]#
PyTorch Dataset for time series data stored in pandas DataFrame.
- Parameters:
data (pd.DataFrame) – data frame with sequence data. Column names must all be str, and contain str as referred to below.
data_future (pd.DataFrame, optional, default=None) – data frame with future data. Column names must all be str, and contain str as referred to below. May contain only columns that are in time, group, weight, known, or static.
time (str, optional, default = first col not in group_ids, weight, target, static.) – integer typed column denoting the time index within
data. This column is used to determine the sequence of samples. If there are no missing observations, the time index should increase by+1for each subsequent sample. The first time_idx for each series does not necessarily have to be0but any value is allowed.target (str or List[str], optional, default = last column (at iloc -1)) – column(s) in
datadenoting the forecasting target. Can be categorical or numerical dtype.group (List[str], optional, default = None) – list of column names identifying a time series instance within
data. This means that thegrouptogether uniquely identify an instance, andgrouptogether withtimeuniquely identify a single observation within a time series instance. IfNone, the dataset is assumed to be a single time series.weight (str, optional, default=None) – column name for weights. If
None, it is assumed that there is no weight column.num (list of str, optional, default = all columns with dtype in "fi") – list of numerical variables in
data, list may also contain list of str, which are then grouped together.cat (list of str, optional, default = all columns with dtype in "Obc") – list of categorical variables in
data, list may also contain list of str, which are then grouped together (e.g. useful for product categories).known (list of str, optional, default = all variables) – list of variables that change over time and are known in the future, list may also contain list of str, which are then grouped together (e.g. useful for special days or promotion categories).
unknown (list of str, optional, default = no variables) – list of variables that are not known in the future, list may also contain list of str, which are then grouped together (e.g. useful for weather categories).
static (list of str, optional, default = all variables not in known, unknown) – list of variables that do not change over time, list may also contain list of str, which are then grouped together.
- __init__(data: DataFrame, data_future: DataFrame | None = None, time: str | None = None, target: str | list[str] | None = None, group: list[str] | None = None, weight: str | None = None, num: list[str | list[str]] | None = None, cat: list[str | list[str]] | None = None, known: list[str | list[str]] | None = None, unknown: list[str | list[str]] | None = None, static: list[str | list[str]] | None = None)[source]#
Methods
__add__(other)__class_getitem__Parameterizes a generic class.
__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(value, /)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__getitem__(index)Get time series data for given index.
__getstate__()Helper for pickle.
__gt__(value, /)Return self>value.
__hash__()Return hash(self).
__init_subclass__Function to initialize subclasses.
__le__(value, /)Return self<=value.
__len__()Return number of time series in the dataset.
__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(*args, **kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
_prepare_metadata()Prepare metadata for the dataset.
get_metadata()Return metadata about the dataset.
Attributes
__annotations____dict____doc____module____orig_bases____parameters____weakref__list of weak references to the object