Skip to content

Pandas fragmentation warning with AddMissingIndicator #886

@jose-cano

Description

@jose-cano

Pandas fragmentation warning with AddMissingIndicator.

Tested behavior when using AddMissingIndicator in a pipeline with cross validation.

Assuming the fix would be to change line 164 and 165 of the AddMissingIndicator class from:

indicator_names = [f"{feature}_na" for feature in self.variables_]
X[indicator_names] = X[self.variables_].isna().astype(int)

To something like:

indicator_df = (X[self.variables_].isna().astype(int).rename(columns=lambda c: f"{c}_na"))
X = pd.concat([X, indicator_df], axis=1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions