_OneSegmentResampleWithDistributionTransform

class _OneSegmentResampleWithDistributionTransform(in_column: str, distribution_column: str, inplace: bool, out_column: str)[source]

Bases: etna.transforms.base.OneSegmentTransform

_OneSegmentResampleWithDistributionTransform resamples the given column using the distribution of the other column.

Init _OneSegmentResampleWithDistributionTransform.

Parameters
  • in_column (str) – name of column to be resampled

  • distribution_column (str) – name of column to obtain the distribution from

  • inplace (bool) –

    • if True, apply resampling inplace to in_column,

    • if False, add transformed column to dataset

  • out_column (str) – name of added column. If not given, use self.__repr__()

Inherited-members

Methods

fit(df)

Obtain the resampling frequency and distribution from distribution_column.

fit_transform(df)

Fit and transform Dataframe.

inverse_transform(df)

Inverse transform Dataframe.

set_params(**params)

Return new object instance with modified parameters.

to_dict()

Collect all information about etna object in dict.

transform(df)

Resample the in_column using the distribution of distribution_column.

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

Obtain the resampling frequency and distribution from distribution_column.

Parameters

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

Return type

etna.transforms.missing_values.resample._OneSegmentResampleWithDistributionTransform

fit_transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame

Fit and transform Dataframe.

May be reimplemented. But it is not recommended.

Parameters

df (pandas.core.frame.DataFrame) – Dataframe in etna long format to transform.

Returns

Transformed Dataframe.

Return type

pandas.core.frame.DataFrame

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

Inverse transform Dataframe.

Parameters

df (pandas.core.frame.DataFrame) –

Return type

pandas.core.frame.DataFrame

set_params(**params: dict) etna.core.mixins.TMixin

Return new object instance with modified parameters.

Method also allows to change parameters of nested objects within the current object. For example, it is possible to change parameters of a model in a Pipeline.

Nested parameters are expected to be in a <component_1>.<...>.<parameter> form, where components are separated by a dot.

Parameters
  • **params – Estimator parameters

  • self (etna.core.mixins.TMixin) –

  • params (dict) –

Returns

New instance with changed parameters

Return type

etna.core.mixins.TMixin

Examples

>>> from etna.pipeline import Pipeline
>>> from etna.models import NaiveModel
>>> from etna.transforms import AddConstTransform
>>> model = model=NaiveModel(lag=1)
>>> transforms = [AddConstTransform(in_column="target", value=1)]
>>> pipeline = Pipeline(model, transforms=transforms, horizon=3)
>>> pipeline.set_params(**{"model.lag": 3, "transforms.0.value": 2})
Pipeline(model = NaiveModel(lag = 3, ), transforms = [AddConstTransform(in_column = 'target', value = 2, inplace = True, out_column = None, )], horizon = 3, )
to_dict()

Collect all information about etna object in dict.

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

Resample the in_column using the distribution of distribution_column.

Parameters

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

Returns

result dataframe

Return type

pandas.core.frame.DataFrame