Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41651a1

Browse files
glemaitreogrisel
authored andcommitted
[MRG] FIX passthrough parameter from make_column_transformer to ColumnTransformer (#11183)
1 parent 4e166e2 commit 41651a1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

sklearn/compose/_column_transformer.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,15 @@ def make_column_transformer(*transformers, **kwargs):
609609
----------
610610
*transformers : tuples of column selections and transformers
611611
612+
remainder : {'passthrough', 'drop'}, default 'passthrough'
613+
By default, all remaining columns that were not specified in
614+
`transformers` will be automatically passed through (default of
615+
``'passthrough'``). This subset of columns is concatenated with the
616+
output of the transformers.
617+
By using ``remainder='drop'``, only the specified columns in
618+
`transformers` are transformed and combined in the output, and the
619+
non-specified columns are dropped.
620+
612621
n_jobs : int, optional
613622
Number of jobs to run in parallel (default 1).
614623
@@ -641,8 +650,10 @@ def make_column_transformer(*transformers, **kwargs):
641650
642651
"""
643652
n_jobs = kwargs.pop('n_jobs', 1)
653+
remainder = kwargs.pop('remainder', 'passthrough')
644654
if kwargs:
645655
raise TypeError('Unknown keyword arguments: "{}"'
646656
.format(list(kwargs.keys())[0]))
647657
transformer_list = _get_transformer_list(transformers)
648-
return ColumnTransformer(transformer_list, n_jobs=n_jobs)
658+
return ColumnTransformer(transformer_list, n_jobs=n_jobs,
659+
remainder=remainder)

sklearn/compose/tests/test_column_transformer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,13 @@ def test_make_column_transformer_kwargs():
343343
scaler = StandardScaler()
344344
norm = Normalizer()
345345
ct = make_column_transformer(('first', scaler), (['second'], norm),
346-
n_jobs=3)
346+
n_jobs=3, remainder='drop')
347347
assert_equal(
348348
ct.transformers,
349349
make_column_transformer(('first', scaler),
350350
(['second'], norm)).transformers)
351351
assert_equal(ct.n_jobs, 3)
352+
assert_equal(ct.remainder, 'drop')
352353
# invalid keyword parameters should raise an error message
353354
assert_raise_message(
354355
TypeError,

0 commit comments

Comments
 (0)