LambdaTransform

class LambdaTransform(in_column: str, transform_func: Callable[[pandas.core.frame.DataFrame], pandas.core.frame.DataFrame], inplace: bool = True, out_column: Optional[str] = None, inverse_transform_func: Optional[Callable[[pandas.core.frame.DataFrame], pandas.core.frame.DataFrame]] = None)[source]

Bases: etna.transforms.base.Transform

LambdaTransform applies input function for given series.

Init LambdaTransform.

Parameters
  • in_column (str) – column to apply transform

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

  • transform_func (Callable[[pandas.core.frame.DataFrame], pandas.core.frame.DataFrame]) – function to transform data

  • inverse_transform_func (Optional[Callable[[pandas.core.frame.DataFrame], pandas.core.frame.DataFrame]]) – inverse function of transform_func

  • inplace (bool) –

    • if True, apply transformation inplace to in_column,

    • if False, add column and apply transformation to out_column

Warning

throws if inplace=True and out_column is initialized, transformation will be applied inplace

Raises

Value error: – if inplace=True and inverse_transform_func is not defined

Inherited-members

Parameters
  • in_column (str) –

  • transform_func (Callable[[pandas.core.frame.DataFrame], pandas.core.frame.DataFrame]) –

  • inplace (bool) –

  • out_column (Optional[str]) –

  • inverse_transform_func (Optional[Callable[[pandas.core.frame.DataFrame], pandas.core.frame.DataFrame]]) –

Methods

fit(df)

Fit preprocess method, does nothing in LambdaTransform case.

fit_transform(df)

May be reimplemented.

inverse_transform(df)

Apply inverse transformation to the series from df.

transform(df)

Apply lambda transformation to series from df.

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

Fit preprocess method, does nothing in LambdaTransform case.

Parameters

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

Returns

result

Return type

LambdaTransform

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

Apply inverse transformation to the series from df.

Parameters

df (pandas.core.frame.DataFrame) – series to transform

Returns

transformed series

Return type

pandas.core.frame.DataFrame

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

Apply lambda transformation to series from df.

Parameters

df (pandas.core.frame.DataFrame) – series to transform

Returns

transformed series

Return type

pandas.core.frame.DataFrame