Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fixed: Unexpected Dropping of columns #263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions sklearn_pandas/dataframe_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,22 @@ def _build(self, X=None):
"""
Build attributes built_features and built_default.
"""

if isinstance(self.features, list):
self.built_features = [
_build_feature(*f, X=X) for f in self.features
]

filtered_list = []
for obj in self.features:
if isinstance(obj[0], list):
new_cols = [col for col in obj[0] if col not in self.drop_cols]

new_tuple = tuple([new_cols] + list(obj[1:]))
filtered_list.append(new_tuple)
else:
if obj[0] not in self.drop_cols:
filtered_list.append(obj)
self.features = filtered_list

self.built_features = [_build_feature(*f, X=X) for f in self.features]
else:
self.built_features = _build_feature(*self.features, X=X)
self.built_default = _build_transformer(self.default)
Expand Down Expand Up @@ -322,6 +334,7 @@ def _transform(self, X, y=None, do_fit=False):
Avoids code duplication for implementation of transform and
fit_transform.
"""

if do_fit:
self._build(X=X)

Expand Down