_SingleDifferencingTransform

class _SingleDifferencingTransform(in_column: str, period: int = 1, inplace: bool = True, out_column: Optional[str] = None)[source]

Bases: etna.transforms.base.Transform

Calculate a time series differences of order 1.

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 _SingleDifferencingTransform.

Parameters
  • in_column (str) – name of processed column

  • period (int) – number of steps back to calculate the difference with, 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

Inherited-members

Methods

fit(df)

Fit the transform.

fit_transform(df)

May be reimplemented.

inverse_transform(df)

Apply inverse transformation to DataFrame.

transform(df)

Make a differencing transformation.

fit(df: pandas.core.frame.DataFrame) etna.transforms.math.differencing._SingleDifferencingTransform[source]

Fit the transform.

Parameters

df (pandas.core.frame.DataFrame) – dataframe with data.

Returns

result

Return type

_SingleDifferencingTransform

inverse_transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]

Apply inverse transformation to DataFrame.

Parameters

df (pandas.core.frame.DataFrame) – DataFrame to apply inverse transform.

Returns

result – transformed DataFrame.

Return type

pd.DataFrame

transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]

Make a differencing transformation.

Parameters

df (pandas.core.frame.DataFrame) – dataframe with data to transform.

Returns

result – transformed dataframe

Return type

pd.Dataframe