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

Make DataFrameMapper.transform thread safe #194

Merged
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
11 changes: 7 additions & 4 deletions sklearn_pandas/dataframe_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def _transform(self, X, y=None, do_fit=False):
self._build()

extracted = []
self.transformed_names_ = []
transformed_names_ = []
for columns, transformers, options in self.built_features:
input_df = options.get('input_df', self.input_df)

Expand Down Expand Up @@ -333,10 +333,11 @@ def _transform(self, X, y=None, do_fit=False):
extracted.append(_handle_feature(Xt))

alias = options.get('alias')

prefix = options.get('prefix', '')
suffix = options.get('suffix', '')

self.transformed_names_ += self.get_names(
transformed_names_ += self.get_names(
columns, transformers, Xt, alias, prefix, suffix)

# handle features not explicitly selected
Expand All @@ -351,15 +352,17 @@ def _transform(self, X, y=None, do_fit=False):
if do_fit:
_call_fit(self.built_default.fit, Xt, y)
Xt = self.built_default.transform(Xt)
self.transformed_names_ += self.get_names(
transformed_names_ += self.get_names(
unsel_cols, self.built_default, Xt)
else:
# if not applying a default transformer,
# keep column names unmodified
self.transformed_names_ += unsel_cols
transformed_names_ += unsel_cols

extracted.append(_handle_feature(Xt))

self.transformed_names_ = transformed_names_

# combine the feature outputs into one array.
# at this point we lose track of which features
# were created from which input columns, so it's
Expand Down