Skip to content

Unexpected Dropping of columns #257

Open
@minorchange

Description

@minorchange

In the following lines the resulting prints do not change if the line drop_cols=["salary"] is commented out:

import sklearn.preprocessing
import pandas as pd
import sklearn_pandas


data = pd.DataFrame(
    {
        "pet": ["cat", "dog", "dog", "fish", "cat", "dog", "cat", "fish"],
        "children": [4.0, 6, 3, 3, 2, 3, 5, 4],
        "salary": [90.0, 24, 44, 27, 32, 59, 36, 27],
    }
)

mapper = sklearn_pandas.DataFrameMapper(
    [
        ("pet", sklearn.preprocessing.LabelBinarizer()),
        (["children"], sklearn.preprocessing.StandardScaler()),
    ],
    input_df=True,
    df_out=True,
    drop_cols=["salary"],
)

print(data)
print()
print(mapper.fit_transform(data.copy()))

In both the uncommented and the commented case there is no salary column in the transformed dataframe. I would have expected that unmentioned columns are not touched, especially since the drop_cols option exists.

Is this just me having arbitrary expectations or is there something strange going on?

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