Skip to content

Commit e85877a

Browse files
authored
Bugfix: attribute naming consistency, drop_cols (#219)
* Bugfix: attribute naming consistency, drop_cols Within the scikit-learn ecosystem, it is standard practice to name the attributes like the init arguments. In this way the get_parms method can get the attributes. From sklearn version 24 onwards this is required behavior. * Bugfix: drop_cols incorrectly creates new list object * drop_cols get state default from None to List * Update changelog and contribution list * Formatting * Bump version to 2.0.2
1 parent fb01a23 commit e85877a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,12 @@ can be easily serialized.
445445

446446
Changelog
447447
---------
448+
2.0.2 (2020-10-01)
449+
******************
450+
451+
* Fix `DataFrameMapper` drop_cols attribute naming consistency with scikit-learn and initialization.
452+
453+
448454
2.0.1 (2020-09-07)
449455
******************
450456

@@ -585,3 +591,4 @@ Other contributors:
585591
* Vitaley Zaretskey (@vzaretsk)
586592
* Zac Stewart (@zacstewart)
587593
* Parul Singh (@paro1234)
594+
* Vincent Heusinkveld (@VHeusinkveld)

sklearn_pandas/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
__version__ = '2.0.1'
1+
__version__ = '2.0.2'
22

33
from .dataframe_mapper import DataFrameMapper # NOQA
44
from .features_generator import gen_features # NOQA
5-
from .transformers import NumericalTransformer # NOQA
5+
from .transformers import NumericalTransformer # NOQA

sklearn_pandas/dataframe_mapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(self, features, default=False, sparse=False, df_out=False,
105105
self.sparse = sparse
106106
self.df_out = df_out
107107
self.input_df = input_df
108-
self.drop_columns = drop_cols or []
108+
self.drop_cols = [] if drop_cols is None else drop_cols
109109
self.transformed_names_ = []
110110

111111
if (df_out and (sparse or default)):
@@ -147,7 +147,7 @@ def _unselected_columns(self, X):
147147
X_columns = list(X.columns)
148148
return [column for column in X_columns if
149149
column not in self._selected_columns
150-
and column not in self.drop_columns]
150+
and column not in self.drop_cols]
151151

152152
def __setstate__(self, state):
153153
# compatibility for older versions of sklearn-pandas
@@ -156,7 +156,7 @@ def __setstate__(self, state):
156156
self.default = state.get('default', False)
157157
self.df_out = state.get('df_out', False)
158158
self.input_df = state.get('input_df', False)
159-
self.drop_columns = state.get('drop_cols', None)
159+
self.drop_cols = state.get('drop_cols', [])
160160
self.built_features = state.get('built_features', self.features)
161161
self.built_default = state.get('built_default', self.default)
162162
self.transformed_names_ = state.get('transformed_names_', [])

0 commit comments

Comments
 (0)