_OneSegmentTimeSeriesImputerTransform

class _OneSegmentTimeSeriesImputerTransform(in_column: str, strategy: str, window: int, seasonality: int, default_value: Optional[float])[source]

Bases: etna.transforms.base.Transform

One segment version of transform to fill NaNs in series of a given dataframe.

  • It is assumed that given series begins with first non NaN value.

  • This transform can’t fill NaNs in the future, only on train data.

  • This transform can’t fill NaNs if all values are NaNs. In this case exception is raised.

Create instance of _OneSegmentTimeSeriesImputerTransform.

Parameters
  • in_column (str) – name of processed column

  • strategy (str) –

    filling value in missing timestamps:

    • If “zero”, then replace missing dates with zeros

    • If “mean”, then replace missing dates using the mean in fit stage.

    • If “running_mean” then replace missing dates using mean of subset of data

    • If “forward_fill” then replace missing dates using last existing value

    • If “seasonal” then replace missing dates using seasonal moving average

  • window (int) –

    In case of moving average and seasonality.

    • If window=-1 all previous dates are taken in account

    • Otherwise only window previous dates

  • seasonality (int) – the length of the seasonality

  • default_value (Optional[float]) – value which will be used to impute the NaNs left after applying the imputer with the chosen strategy

Raises

ValueError: – if incorrect strategy given

Inherited-members

Methods

fit(df)

Fit preprocess params.

fit_transform(df)

May be reimplemented.

inverse_transform(df)

Inverse transform dataframe.

transform(df)

Transform given series.

fit(df: pandas.core.frame.DataFrame) etna.transforms.missing_values.imputation._OneSegmentTimeSeriesImputerTransform[source]

Fit preprocess params.

Parameters

df (pd.DataFrame) – dataframe with series to fit preprocess params with

Returns

self – fitted preprocess

Return type

_OneSegmentTimeSeriesImputerTransform

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

Inverse transform dataframe.

Parameters

df (pd.Dataframe) – inverse transform in_column series of given dataframe

Returns

result – dataframe with in_column series with initial values

Return type

pd.DataFrame

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

Transform given series.

Parameters

df (pd.Dataframe) – transform in_column series of given dataframe

Returns

result – dataframe with in_column series with filled gaps

Return type

pd.DataFrame