@@ -210,6 +210,32 @@ attribute.
210210
211211Note this does not work together with the ``default=True `` or ``sparse=True `` arguments to the mapper.
212212
213+ Dropping columns explictly
214+ *******************************
215+
216+ Sometimes it is required to drop a specific column/ list of columns.
217+ For this purpose, ``drop_cols `` argument for ``DataFrameMapper `` can be used.
218+ Default value is ``None ``
219+
220+ >>> mapper_df = DataFrameMapper([
221+ ... (' pet' , sklearn.preprocessing.LabelBinarizer()),
222+ ... ([' children' ], sklearn.preprocessing.StandardScaler())
223+ ... ], drop_cols= [' salary' ])
224+
225+ Now running ``fit_transform `` will run transformations on 'pet' and 'children' and drop 'salary' column:
226+
227+ >>> np.round(mapper_df.fit_transform(data.copy()), 1 )
228+ array([[ 1. , 0. , 0. , 0.2],
229+ [ 0. , 1. , 0. , 1.9],
230+ [ 0. , 1. , 0. , -0.6],
231+ [ 0. , 0. , 1. , -0.6],
232+ [ 1. , 0. , 0. , -1.5],
233+ [ 0. , 1. , 0. , -0.6],
234+ [ 1. , 0. , 0. , 1. ],
235+ [ 0. , 0. , 1. , 0.2]])
236+
237+ Transformations may require multiple input columns. In these
238+
213239Transform Multiple Columns
214240**************************
215241
@@ -395,7 +421,7 @@ The stacking of the sparse features is done without ever densifying them.
395421
396422
397423Using ``NumericalTransformer ``
398- ****************************
424+ ***********************************
399425
400426While you can use ``FunctionTransformation `` to generate arbitrary transformers, it can present serialization issues
401427when pickling. Use ``NumericalTransformer `` instead, which takes the function name as a string parameter and hence
@@ -419,8 +445,15 @@ can be easily serialized.
419445
420446Changelog
421447---------
448+ 2.0.1 (2020-09-07)
449+ ******************
450+
451+ * Added an option to explicitly drop columns.
452+
453+
4224542.0.0 (2020-08-01)
423455******************
456+
424457* Deprecated support for Python < 3.6.
425458* Deprecated support for old versions of scikit-learn, pandas and numpy. Please check setup.py for minimum requirement.
426459* Removed CategoricalImputer, cross_val_score and GridSearchCV. All these functionality now exists as part of
@@ -430,32 +463,39 @@ Changelog
430463* Added ``NumericalTransformer `` for common numerical transformations. Currently it implements log and log1p
431464 transformation.
432465* Added prefix and suffix options. See examples above. These are usually helpful when using gen_features.
466+ * Added ``drop_cols `` argument to DataframeMapper. This can be used to explicitly drop columns
433467
434468
4354691.8.0 (2018-12-01)
436470******************
471+
437472* Add ``FunctionTransformer `` class (#117).
438473* Fix column names derivation for dataframes with multi-index or non-string
439474 columns (#166).
440475* Change behaviour of DataFrameMapper's fit_transform method to invoke each underlying transformers'
441476 native fit_transform if implemented. (#150)
442477
478+
4434791.7.0 (2018-08-15)
444480******************
481+
445482* Fix issues with unicode names in ``get_names `` (#160).
446483* Update to build using ``numpy==1.14 `` and ``python==3.6 `` (#154).
447484* Add ``strategy `` and ``fill_value `` parameters to ``CategoricalImputer `` to allow imputing
448485 with values other than the mode (#144), (#161).
449486* Preserve input data types when no transform is supplied (#138).
450487
488+
4514891.6.0 (2017-10-28)
452490******************
491+
453492* Add column name to exception during fit/transform (#110).
454493* Add ``gen_feature `` helper function to help generating the same transformation for multiple columns (#126).
455494
456495
4574961.5.0 (2017-06-24)
458497******************
498+
459499* Allow inputting a dataframe/series per group of columns.
460500* Get feature names also from ``estimator.get_feature_names() `` if present.
461501* Attempt to derive feature names from individual transformers when applying a
@@ -466,6 +506,7 @@ Changelog
466506
4675071.4.0 (2017-05-13)
468508******************
509+
469510* Allow specifying a custom name (alias) for transformed columns (#83).
470511* Capture output columns generated names in ``transformed_names_ `` attribute (#78).
471512* Add ``CategoricalImputer `` that replaces null-like values with the mode
@@ -543,3 +584,4 @@ Other contributors:
543584* Timothy Sweetser (@hacktuarial)
544585* Vitaley Zaretskey (@vzaretsk)
545586* Zac Stewart (@zacstewart)
587+ * Parul Singh (@paro1234)
0 commit comments