Skip to content

Base class

The abstract interface every imputer implements.

Abstract base class shared by every imputer.

ImputationError

Bases: RuntimeError

An imputer's model could not be fitted and on_error="raise" was set.

BaseImputer

Bases: ABC

Base class for all imputation methods.

Subclasses implement :meth:impute, which must return a new dataframe and leave the input untouched.

impute abstractmethod

impute(df: DataFrame) -> DataFrame

Impute missing values in df.

Parameters:

Name Type Description Default
df DataFrame

Dataframe with potential NaN values.

required

Returns:

Type Description
DataFrame

Dataframe with imputed values.

Source code in src/imputation_methods/base.py
@abstractmethod
def impute(self, df: pd.DataFrame) -> pd.DataFrame:
    """Impute missing values in ``df``.

    Args:
        df: Dataframe with potential NaN values.

    Returns:
        Dataframe with imputed values.
    """