Skip to content

Functional API

One *_impute(df, ...) shortcut per imputer.

Functional shortcuts: one *_impute(df, ...) function per imputer.

Each function builds the corresponding imputer with the given parameters and immediately applies it to df.

mean_impute

mean_impute(df: DataFrame) -> DataFrame

Backwards-compatible wrapper for :class:MeanImputer.

Source code in src/imputation_methods/functional.py
def mean_impute(df: pd.DataFrame) -> pd.DataFrame:
    """Backwards-compatible wrapper for :class:`MeanImputer`."""
    return MeanImputer().impute(df)

median_impute

median_impute(df: DataFrame) -> DataFrame

Backwards-compatible wrapper for :class:MedianImputer.

Source code in src/imputation_methods/functional.py
def median_impute(df: pd.DataFrame) -> pd.DataFrame:
    """Backwards-compatible wrapper for :class:`MedianImputer`."""
    return MedianImputer().impute(df)

knn_impute

knn_impute(df: DataFrame, n_neighbors: int = 5, on_error: OnError = None) -> DataFrame

Wrapper for :class:KNNImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(k="n_neighbors")
def knn_impute(
    df: pd.DataFrame, n_neighbors: int = 5, on_error: OnError = None
) -> pd.DataFrame:
    """Wrapper for :class:`KNNImputer`."""
    return KNNImputer(n_neighbors=n_neighbors, on_error=on_error).impute(df)

pmm_impute

pmm_impute(df: DataFrame, n_neighbors: int = 5, random_state: int | None = None, on_error: OnError = None) -> DataFrame

Wrapper for :class:PMMImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(k="n_neighbors")
def pmm_impute(
    df: pd.DataFrame,
    n_neighbors: int = 5,
    random_state: int | None = None,
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`PMMImputer`."""
    return PMMImputer(
        n_neighbors=n_neighbors, random_state=random_state, on_error=on_error
    ).impute(df)

mice_impute

mice_impute(df: DataFrame, random_state: int | None = None, on_error: OnError = None) -> DataFrame

Backwards-compatible wrapper for :class:MICEImputer.

Source code in src/imputation_methods/functional.py
def mice_impute(
    df: pd.DataFrame, random_state: int | None = None, on_error: OnError = None
) -> pd.DataFrame:
    """Backwards-compatible wrapper for :class:`MICEImputer`."""
    return MICEImputer(random_state=random_state, on_error=on_error).impute(df)

regression_impute

regression_impute(df: DataFrame, on_error: OnError = None) -> DataFrame

Backwards-compatible wrapper for :class:RegressionImputer.

Source code in src/imputation_methods/functional.py
def regression_impute(df: pd.DataFrame, on_error: OnError = None) -> pd.DataFrame:
    """Backwards-compatible wrapper for :class:`RegressionImputer`."""
    return RegressionImputer(on_error=on_error).impute(df)

stochastic_regression_impute

stochastic_regression_impute(df: DataFrame, random_state: int | None = None) -> DataFrame

Wrapper for :class:StochasticRegressionImputer.

Source code in src/imputation_methods/functional.py
def stochastic_regression_impute(
    df: pd.DataFrame, random_state: int | None = None
) -> pd.DataFrame:
    """Wrapper for :class:`StochasticRegressionImputer`."""
    return StochasticRegressionImputer(random_state=random_state).impute(df)

locf_impute

locf_impute(df: DataFrame) -> DataFrame

Backwards-compatible wrapper for :class:LOCFImputer.

Source code in src/imputation_methods/functional.py
def locf_impute(df: pd.DataFrame) -> pd.DataFrame:
    """Backwards-compatible wrapper for :class:`LOCFImputer`."""
    return LOCFImputer().impute(df)

nocb_impute

nocb_impute(df: DataFrame) -> DataFrame

Backwards-compatible wrapper for :class:NOCBImputer.

Source code in src/imputation_methods/functional.py
def nocb_impute(df: pd.DataFrame) -> pd.DataFrame:
    """Backwards-compatible wrapper for :class:`NOCBImputer`."""
    return NOCBImputer().impute(df)

hot_deck_impute

hot_deck_impute(df: DataFrame, stratify_cols: list[str] | None = None, random_state: int | None = None) -> DataFrame

Wrapper for :class:HotDeckImputer.

Source code in src/imputation_methods/functional.py
def hot_deck_impute(
    df: pd.DataFrame,
    stratify_cols: list[str] | None = None,
    random_state: int | None = None,
) -> pd.DataFrame:
    """Wrapper for :class:`HotDeckImputer`."""
    return HotDeckImputer(
        stratify_cols=stratify_cols,
        random_state=random_state,
    ).impute(df)

miss_forest_impute

miss_forest_impute(df: DataFrame, random_state: int | None = None, on_error: OnError = None) -> DataFrame

Wrapper for :class:MissForestImputer.

Source code in src/imputation_methods/functional.py
def miss_forest_impute(
    df: pd.DataFrame, random_state: int | None = None, on_error: OnError = None
) -> pd.DataFrame:
    """Wrapper for :class:`MissForestImputer`."""
    return MissForestImputer(random_state=random_state, on_error=on_error).impute(df)

ppca_impute

ppca_impute(df: DataFrame, n_components: int | None = 1, min_obs: int = 1, max_iter: int = 500, tol: float = 1e-06, on_error: OnError = None) -> DataFrame

Wrapper for :class:PPCAImputer.

Source code in src/imputation_methods/functional.py
def ppca_impute(
    df: pd.DataFrame,
    n_components: int | None = 1,
    min_obs: int = 1,
    max_iter: int = 500,
    tol: float = 1e-6,
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`PPCAImputer`."""
    return PPCAImputer(
        n_components=n_components,
        min_obs=min_obs,
        max_iter=max_iter,
        tol=tol,
        on_error=on_error,
    ).impute(df)

soft_impute

soft_impute(df: DataFrame, max_iter: int = 100, init_fill_method: str = 'zero', shrinkage_value: float | None = None, convergence_threshold: float = 0.001, on_error: OnError = None) -> DataFrame

Wrapper for :class:SoftImputeImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(max_iters="max_iter")
def soft_impute(
    df: pd.DataFrame,
    max_iter: int = 100,
    init_fill_method: str = "zero",
    shrinkage_value: float | None = None,
    convergence_threshold: float = 1e-3,
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`SoftImputeImputer`."""
    return SoftImputeImputer(
        max_iter=max_iter,
        init_fill_method=init_fill_method,
        shrinkage_value=shrinkage_value,
        convergence_threshold=convergence_threshold,
        on_error=on_error,
    ).impute(df)

autoencoder_impute

autoencoder_impute(df: DataFrame, hidden_layer_sizes: tuple[int, ...] = (10,), max_iter: int = 200, random_state: int | None = None, on_error: OnError = None) -> DataFrame

Wrapper for :class:AutoencoderImputer.

Source code in src/imputation_methods/functional.py
def autoencoder_impute(
    df: pd.DataFrame,
    hidden_layer_sizes: tuple[int, ...] = (10,),
    max_iter: int = 200,
    random_state: int | None = None,
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`AutoencoderImputer`."""
    return AutoencoderImputer(
        hidden_layer_sizes=hidden_layer_sizes,
        max_iter=max_iter,
        random_state=random_state,
        on_error=on_error,
    ).impute(df)

gain_impute

gain_impute(df: DataFrame, batch_size: int = 128, hint_rate: float = 0.9, alpha: float = 100.0, max_iter: int = 10000, learning_rate: float = 0.001, random_state: int | None = None) -> DataFrame

Wrapper for :class:GAINImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(iterations="max_iter")
def gain_impute(
    df: pd.DataFrame,
    batch_size: int = 128,
    hint_rate: float = 0.9,
    alpha: float = 100.0,
    max_iter: int = 10000,
    learning_rate: float = 0.001,
    random_state: int | None = None,
) -> pd.DataFrame:
    """Wrapper for :class:`GAINImputer`."""
    return GAINImputer(
        batch_size=batch_size,
        hint_rate=hint_rate,
        alpha=alpha,
        max_iter=max_iter,
        learning_rate=learning_rate,
        random_state=random_state,
    ).impute(df)

gaussian_process_impute

gaussian_process_impute(df: DataFrame, kernel: RBF | None = None, alpha: float = 1e-10, random_state: int | None = None, on_error: OnError = None) -> DataFrame

Wrapper for :class:GaussianProcessImputer.

Source code in src/imputation_methods/functional.py
def gaussian_process_impute(
    df: pd.DataFrame,
    kernel: RBF | None = None,
    alpha: float = 1e-10,
    random_state: int | None = None,
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`GaussianProcessImputer`."""
    return GaussianProcessImputer(
        kernel=kernel, alpha=alpha, random_state=random_state, on_error=on_error
    ).impute(df)

interpolation_impute

interpolation_impute(df: DataFrame, method: str = 'linear', order: int = 2, limit: int | None = None, limit_direction: Literal['forward', 'backward', 'both'] = 'both') -> DataFrame

Wrapper for :class:InterpolationImputer.

Source code in src/imputation_methods/functional.py
def interpolation_impute(
    df: pd.DataFrame,
    method: str = "linear",
    order: int = 2,
    limit: int | None = None,
    limit_direction: Literal["forward", "backward", "both"] = "both",
) -> pd.DataFrame:
    """Wrapper for :class:`InterpolationImputer`."""
    return InterpolationImputer(
        method=method, order=order, limit=limit, limit_direction=limit_direction
    ).impute(df)

em_impute

em_impute(df: DataFrame, max_iter: int = 100, tol: float = 0.0001, random_state: int | None = None) -> DataFrame

Wrapper for :class:EMImputer.

Source code in src/imputation_methods/functional.py
def em_impute(
    df: pd.DataFrame,
    max_iter: int = 100,
    tol: float = 1e-4,
    random_state: int | None = None,
) -> pd.DataFrame:
    """Wrapper for :class:`EMImputer`."""
    return EMImputer(max_iter=max_iter, tol=tol, random_state=random_state).impute(df)

moving_average_impute

moving_average_impute(df: DataFrame, window: int = 3, strategy: str = 'mean', min_periods: int = 1, center: bool = False) -> DataFrame

Wrapper for :class:MovingAverageImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(method="strategy")
def moving_average_impute(
    df: pd.DataFrame,
    window: int = 3,
    strategy: str = "mean",
    min_periods: int = 1,
    center: bool = False,
) -> pd.DataFrame:
    """Wrapper for :class:`MovingAverageImputer`."""
    return MovingAverageImputer(
        window=window, strategy=strategy, min_periods=min_periods, center=center
    ).impute(df)

random_sampling_impute

random_sampling_impute(df: DataFrame, random_state: int | None = None) -> DataFrame

Wrapper for :class:RandomSamplingImputer.

Source code in src/imputation_methods/functional.py
def random_sampling_impute(
    df: pd.DataFrame, random_state: int | None = None
) -> pd.DataFrame:
    """Wrapper for :class:`RandomSamplingImputer`."""
    return RandomSamplingImputer(random_state=random_state).impute(df)

indicator_impute

indicator_impute(df: DataFrame, strategy: str = 'mean', indicator_prefix: str = 'missing_') -> DataFrame

Wrapper for :class:IndicatorImputer.

Source code in src/imputation_methods/functional.py
def indicator_impute(
    df: pd.DataFrame, strategy: str = "mean", indicator_prefix: str = "missing_"
) -> pd.DataFrame:
    """Wrapper for :class:`IndicatorImputer`."""
    return IndicatorImputer(
        strategy=strategy, indicator_prefix=indicator_prefix
    ).impute(df)

seasonal_impute

seasonal_impute(df: DataFrame, period: int = 7, strategy: str = 'median') -> DataFrame

Wrapper for :class:SeasonalImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(method="strategy")
def seasonal_impute(
    df: pd.DataFrame, period: int = 7, strategy: str = "median"
) -> pd.DataFrame:
    """Wrapper for :class:`SeasonalImputer`."""
    return SeasonalImputer(period=period, strategy=strategy).impute(df)

quantile_impute

quantile_impute(df: DataFrame, quantile: float = 0.5) -> DataFrame

Wrapper for :class:QuantileImputer.

Source code in src/imputation_methods/functional.py
def quantile_impute(df: pd.DataFrame, quantile: float = 0.5) -> pd.DataFrame:
    """Wrapper for :class:`QuantileImputer`."""
    return QuantileImputer(quantile=quantile).impute(df)

forward_fill_fallback_impute

forward_fill_fallback_impute(df: DataFrame, fallback: str = 'mean') -> DataFrame

Wrapper for :class:ForwardFillFallbackImputer.

Source code in src/imputation_methods/functional.py
def forward_fill_fallback_impute(
    df: pd.DataFrame, fallback: str = "mean"
) -> pd.DataFrame:
    """Wrapper for :class:`ForwardFillFallbackImputer`."""
    return ForwardFillFallbackImputer(fallback=fallback).impute(df)

mode_impute

mode_impute(df: DataFrame, dropna: bool = True) -> DataFrame

Wrapper for :class:ModeImputer.

Source code in src/imputation_methods/functional.py
def mode_impute(df: pd.DataFrame, dropna: bool = True) -> pd.DataFrame:
    """Wrapper for :class:`ModeImputer`."""
    return ModeImputer(dropna=dropna).impute(df)

constant_impute

constant_impute(df: DataFrame, fill_value: float | dict[str, float] = 0) -> DataFrame

Wrapper for :class:ConstantImputer.

Source code in src/imputation_methods/functional.py
def constant_impute(
    df: pd.DataFrame, fill_value: float | dict[str, float] = 0
) -> pd.DataFrame:
    """Wrapper for :class:`ConstantImputer`."""
    return ConstantImputer(fill_value=fill_value).impute(df)

end_of_distribution_impute

end_of_distribution_impute(df: DataFrame, position: str = 'high', n_std: float = 3.0) -> DataFrame

Wrapper for :class:EndOfDistributionImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(k="n_std")
def end_of_distribution_impute(
    df: pd.DataFrame, position: str = "high", n_std: float = 3.0
) -> pd.DataFrame:
    """Wrapper for :class:`EndOfDistributionImputer`."""
    return EndOfDistributionImputer(position=position, n_std=n_std).impute(df)

group_mean_impute

group_mean_impute(df: DataFrame, group_col: str, strategy: str = 'mean', global_fallback: bool = True) -> DataFrame

Wrapper for :class:GroupMeanImputer.

Source code in src/imputation_methods/functional.py
@renamed_parameters(method="strategy")
def group_mean_impute(
    df: pd.DataFrame,
    group_col: str,
    strategy: str = "mean",
    global_fallback: bool = True,
) -> pd.DataFrame:
    """Wrapper for :class:`GroupMeanImputer`."""
    return GroupMeanImputer(
        group_col=group_col, strategy=strategy, global_fallback=global_fallback
    ).impute(df)

weighted_moving_average_impute

weighted_moving_average_impute(df: DataFrame, alpha: float = 0.5, min_periods: int = 1) -> DataFrame

Wrapper for :class:WeightedMovingAverageImputer.

Source code in src/imputation_methods/functional.py
def weighted_moving_average_impute(
    df: pd.DataFrame, alpha: float = 0.5, min_periods: int = 1
) -> pd.DataFrame:
    """Wrapper for :class:`WeightedMovingAverageImputer`."""
    return WeightedMovingAverageImputer(alpha=alpha, min_periods=min_periods).impute(df)

linear_trend_impute

linear_trend_impute(df: DataFrame, use_index: bool = False) -> DataFrame

Wrapper for :class:LinearTrendImputer.

Source code in src/imputation_methods/functional.py
def linear_trend_impute(df: pd.DataFrame, use_index: bool = False) -> pd.DataFrame:
    """Wrapper for :class:`LinearTrendImputer`."""
    return LinearTrendImputer(use_index=use_index).impute(df)

polynomial_trend_impute

polynomial_trend_impute(df: DataFrame, degree: int = 2, use_index: bool = False) -> DataFrame

Wrapper for :class:PolynomialTrendImputer.

Source code in src/imputation_methods/functional.py
def polynomial_trend_impute(
    df: pd.DataFrame, degree: int = 2, use_index: bool = False
) -> pd.DataFrame:
    """Wrapper for :class:`PolynomialTrendImputer`."""
    return PolynomialTrendImputer(degree=degree, use_index=use_index).impute(df)

kalman_filter_impute

kalman_filter_impute(df: DataFrame, process_variance: float = 1.0, measurement_variance: float = 1.0, initial_state: float | None = None, initial_covariance: float = 1.0) -> DataFrame

Wrapper for :class:KalmanFilterImputer.

Source code in src/imputation_methods/functional.py
def kalman_filter_impute(
    df: pd.DataFrame,
    process_variance: float = 1.0,
    measurement_variance: float = 1.0,
    initial_state: float | None = None,
    initial_covariance: float = 1.0,
) -> pd.DataFrame:
    """Wrapper for :class:`KalmanFilterImputer`."""
    return KalmanFilterImputer(
        process_variance=process_variance,
        measurement_variance=measurement_variance,
        initial_state=initial_state,
        initial_covariance=initial_covariance,
    ).impute(df)

cold_deck_impute

cold_deck_impute(df: DataFrame, reference_values: ReferenceValues | None = None, random_state: int | None = None) -> DataFrame

Wrapper for :class:ColdDeckImputer.

Source code in src/imputation_methods/functional.py
def cold_deck_impute(
    df: pd.DataFrame,
    reference_values: ReferenceValues | None = None,
    random_state: int | None = None,
) -> pd.DataFrame:
    """Wrapper for :class:`ColdDeckImputer`."""
    return ColdDeckImputer(
        reference_values=reference_values, random_state=random_state
    ).impute(df)

hybrid_impute

hybrid_impute(df: DataFrame, methods: list[BaseImputer] | None = None) -> DataFrame

Wrapper for :class:HybridImputer.

Source code in src/imputation_methods/functional.py
def hybrid_impute(
    df: pd.DataFrame, methods: list[BaseImputer] | None = None
) -> pd.DataFrame:
    """Wrapper for :class:`HybridImputer`."""
    return HybridImputer(methods=methods).impute(df)

bayesian_ridge_impute

bayesian_ridge_impute(df: DataFrame, max_iter: int = 300, tol: float = 0.001, alpha_1: float = 1e-06, alpha_2: float = 1e-06, lambda_1: float = 1e-06, lambda_2: float = 1e-06) -> DataFrame

Wrapper for :class:BayesianRidgeImputer.

Source code in src/imputation_methods/functional.py
def bayesian_ridge_impute(
    df: pd.DataFrame,
    max_iter: int = 300,
    tol: float = 1e-3,
    alpha_1: float = 1e-6,
    alpha_2: float = 1e-6,
    lambda_1: float = 1e-6,
    lambda_2: float = 1e-6,
) -> pd.DataFrame:
    """Wrapper for :class:`BayesianRidgeImputer`."""
    return BayesianRidgeImputer(
        max_iter=max_iter,
        tol=tol,
        alpha_1=alpha_1,
        alpha_2=alpha_2,
        lambda_1=lambda_1,
        lambda_2=lambda_2,
    ).impute(df)

stacking_impute

stacking_impute(df: DataFrame, base_imputers: list[BaseImputer] | None = None, meta_strategy: str = 'mean') -> DataFrame

Wrapper for :class:StackingImputer.

Source code in src/imputation_methods/functional.py
def stacking_impute(
    df: pd.DataFrame,
    base_imputers: list[BaseImputer] | None = None,
    meta_strategy: str = "mean",
) -> pd.DataFrame:
    """Wrapper for :class:`StackingImputer`."""
    return StackingImputer(
        base_imputers=base_imputers, meta_strategy=meta_strategy
    ).impute(df)

bagging_impute

bagging_impute(df: DataFrame, base_imputer: BaseImputer | None = None, n_estimators: int = 10, max_samples: float = 0.8, random_state: int | None = None) -> DataFrame

Wrapper for :class:BaggingImputer.

Source code in src/imputation_methods/functional.py
def bagging_impute(
    df: pd.DataFrame,
    base_imputer: BaseImputer | None = None,
    n_estimators: int = 10,
    max_samples: float = 0.8,
    random_state: int | None = None,
) -> pd.DataFrame:
    """Wrapper for :class:`BaggingImputer`."""
    return BaggingImputer(
        base_imputer=base_imputer,
        n_estimators=n_estimators,
        max_samples=max_samples,
        random_state=random_state,
    ).impute(df)

radius_neighbors_impute

radius_neighbors_impute(df: DataFrame, radius: float = 1.0, weights: str = 'distance', metric: str = 'euclidean', on_error: OnError = None) -> DataFrame

Wrapper for :class:RadiusNeighborsImputer.

Source code in src/imputation_methods/functional.py
def radius_neighbors_impute(
    df: pd.DataFrame,
    radius: float = 1.0,
    weights: str = "distance",
    metric: str = "euclidean",
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`RadiusNeighborsImputer`."""
    return RadiusNeighborsImputer(
        radius=radius, weights=weights, metric=metric, on_error=on_error
    ).impute(df)

local_mean_impute

local_mean_impute(df: DataFrame, n_neighbors: int = 5, distance_weight_power: float = 2.0) -> DataFrame

Wrapper for :class:LocalMeanImputer.

Source code in src/imputation_methods/functional.py
def local_mean_impute(
    df: pd.DataFrame, n_neighbors: int = 5, distance_weight_power: float = 2.0
) -> pd.DataFrame:
    """Wrapper for :class:`LocalMeanImputer`."""
    return LocalMeanImputer(
        n_neighbors=n_neighbors, distance_weight_power=distance_weight_power
    ).impute(df)

huber_impute

huber_impute(df: DataFrame, epsilon: float = 1.35, max_iter: int = 100, alpha: float = 0.0001) -> DataFrame

Wrapper for :class:HuberImputer.

Source code in src/imputation_methods/functional.py
def huber_impute(
    df: pd.DataFrame, epsilon: float = 1.35, max_iter: int = 100, alpha: float = 0.0001
) -> pd.DataFrame:
    """Wrapper for :class:`HuberImputer`."""
    return HuberImputer(epsilon=epsilon, max_iter=max_iter, alpha=alpha).impute(df)

ransac_impute

ransac_impute(df: DataFrame, max_trials: int = 100, random_state: int | None = None, min_samples: int | None = None, residual_threshold: float | None = None, on_error: OnError = None) -> DataFrame

Wrapper for :class:RANSACImputer.

Source code in src/imputation_methods/functional.py
def ransac_impute(
    df: pd.DataFrame,
    max_trials: int = 100,
    random_state: int | None = None,
    min_samples: int | None = None,
    residual_threshold: float | None = None,
    on_error: OnError = None,
) -> pd.DataFrame:
    """Wrapper for :class:`RANSACImputer`."""
    return RANSACImputer(
        min_samples=min_samples,
        residual_threshold=residual_threshold,
        max_trials=max_trials,
        random_state=random_state,
        on_error=on_error,
    ).impute(df)

trimmed_mean_impute

trimmed_mean_impute(df: DataFrame, trim_fraction: float = 0.1) -> DataFrame

Wrapper for :class:TrimmedMeanImputer.

Source code in src/imputation_methods/functional.py
def trimmed_mean_impute(df: pd.DataFrame, trim_fraction: float = 0.1) -> pd.DataFrame:
    """Wrapper for :class:`TrimmedMeanImputer`."""
    return TrimmedMeanImputer(trim_fraction=trim_fraction).impute(df)