DifferencingTransform¶
- class DifferencingTransform(in_column: str, period: int = 1, order: int = 1, inplace: bool = True, out_column: Optional[str] = None)[source]¶
Bases:
etna.transforms.base.Transform
Calculate a time series differences.
This transform can work with NaNs at the beginning of the segment, but fails when meets NaN inside the segment.
Notes
To understand how transform works we recommend: Stationarity and Differencing
Create instance of DifferencingTransform.
- Parameters
in_column (str) – name of processed column
period (int) – number of steps back to calculate the difference with, it should be >= 1
order (int) – number of differences to make, it should be >= 1
inplace (bool) –
if True, apply transformation inplace to in_column,
if False, add transformed column to dataset
out_column (Optional[str]) –
if set, name of added column, the final name will be ‘{out_column}’;
if isn’t set, name will be based on
self.__repr__()
- Raises
ValueError: – if period is not integer >= 1
ValueError: – if order is not integer >= 1
- Inherited-members
Methods
fit
(df)Fit the transform.
fit_transform
(df)May be reimplemented.
Apply inverse transformation to DataFrame.
transform
(df)Make a differencing transformation.
- fit(df: pandas.core.frame.DataFrame) etna.transforms.math.differencing.DifferencingTransform [source]¶
Fit the transform.
- Parameters
df (pandas.core.frame.DataFrame) – dataframe with data.
- Returns
result
- Return type