Additional util functions¶
- class darts.utils.utils.ModelMode(value)[source]¶
Bases:
enum.Enum
An enumeration.
- ADDITIVE = 'additive'¶
- MULTIPLICATIVE = 'multiplicative'¶
- NONE = None¶
- class darts.utils.utils.SeasonalityMode(value)[source]¶
Bases:
enum.Enum
An enumeration.
- ADDITIVE = 'additive'¶
- MULTIPLICATIVE = 'multiplicative'¶
- NONE = None¶
- class darts.utils.utils.TrendMode(value)[source]¶
Bases:
enum.Enum
An enumeration.
- EXPONENTIAL = 'exponential'¶
- LINEAR = 'linear'¶
- darts.utils.utils.drop_after_index(index, split_point)[source]¶
Drops everything after the provided time split_point (excluded) from the index.
- Parameters
index (
Union
[RangeIndex
,DatetimeIndex
]) – The index to drop values from.split_point (
Union
[int
,Timestamp
]) – The timestamp that indicates cut-off time.
- Returns
A new index with values after split_point dropped.
- Return type
Union[pd.RangeIndex, pd.DatetimeIndex]
- darts.utils.utils.drop_before_index(index, split_point)[source]¶
Drops everything before the provided time split_point (excluded) from the index.
- Parameters
index (
Union
[RangeIndex
,DatetimeIndex
]) – The index to drop values from.split_point (
Union
[int
,Timestamp
]) – The timestamp that indicates cut-off time.
- Returns
A new index with values before split_point dropped.
- Return type
Union[pd.RangeIndex, pd.DatetimeIndex]
- darts.utils.utils.get_single_series(ts)[source]¶
Returns a single (first) TimeSeries or None from ts. Returns ts if ts is a TimeSeries, ts[0] if ts is a Sequence of TimeSeries. Otherwise, returns None.
- Parameters
ts (
Union
[TimeSeries
,Sequence
[TimeSeries
],None
]) – None, a single TimeSeries, or a sequence of TimeSeries.- Returns
- Return type
ts if ts is a TimeSeries, ts[0] if ts is a Sequence of TimeSeries. Otherwise, returns None
- darts.utils.utils.retain_period_common_to_all(series)[source]¶
Trims all series in the provided list, if necessary, so that the returned time series have a common span (corresponding to largest time sub-interval common to all series).
- Parameters
series (
List
[TimeSeries
]) – The list of series to consider.- Raises
ValueError – If no common time sub-interval exists
- Returns
A list of series, where each series have the same span
- Return type
List[TimeSeries]
- darts.utils.utils.seq2series(ts)[source]¶
If ts is a Sequence with only a single series, return the single series as TimeSeries.
- Parameters
ts (
Union
[TimeSeries
,Sequence
[TimeSeries
],None
]) – None, a single TimeSeries, or a sequence of TimeSeries- Returns
- Return type
ts if ts if is not a single element TimeSeries sequence, else ts[0]
- darts.utils.utils.series2seq(ts)[source]¶
If ts is a single TimeSeries, return it as a list of a single TimeSeries.
- Parameters
ts (
Union
[TimeSeries
,Sequence
[TimeSeries
],None
]) – None, a single TimeSeries, or a sequence of TimeSeries- Returns
- Return type
ts if ts is not a TimeSeries, else [ts]
- darts.utils.utils.slice_index(index, start, end)[source]¶
Returns a new Index with the same type as the input index, containing the values between start and end included. If start and end are not in the index, the closest values are used instead. The start and end values can be either integers (in which case they are interpreted as indices), or pd.Timestamps (in which case they are interpreted as actual timestamps).
- Parameters
index (
Union
[RangeIndex
,DatetimeIndex
]) – The index to slice.start (
Union
[int
,Timestamp
]) – The start of the returned index.end (
Union
[int
,Timestamp
]) – The end of the returned index.
- Returns
A new index with the same type as the input index, but with only the values between start and end included.
- Return type
Union[pd.RangeIndex, pd.DatetimeIndex]