@@ -405,7 +405,7 @@ def test_column_transformer_get_set_params():
405
405
('trans2' , StandardScaler (), [1 ])])
406
406
407
407
exp = {'n_jobs' : 1 ,
408
- 'remainder' : 'passthrough ' ,
408
+ 'remainder' : 'drop ' ,
409
409
'trans1' : ct .transformers [0 ][1 ],
410
410
'trans1__copy' : True ,
411
411
'trans1__with_mean' : True ,
@@ -424,7 +424,7 @@ def test_column_transformer_get_set_params():
424
424
425
425
ct .set_params (trans1 = 'passthrough' )
426
426
exp = {'n_jobs' : 1 ,
427
- 'remainder' : 'passthrough ' ,
427
+ 'remainder' : 'drop ' ,
428
428
'trans1' : 'passthrough' ,
429
429
'trans2' : ct .transformers [1 ][1 ],
430
430
'trans2__copy' : True ,
@@ -492,7 +492,8 @@ def test_column_transformer_get_feature_names():
492
492
NotImplementedError , 'get_feature_names is not yet supported' ,
493
493
ct .get_feature_names )
494
494
495
- ct = ColumnTransformer ([('trans' , DictVectorizer (), 0 )])
495
+ ct = ColumnTransformer ([('trans' , DictVectorizer (), 0 )],
496
+ remainder = 'passthrough' )
496
497
ct .fit (X )
497
498
assert_raise_message (
498
499
NotImplementedError , 'get_feature_names is not yet supported' ,
@@ -552,23 +553,22 @@ def test_column_transformer_remainder():
552
553
X_res_second = np .array ([2 , 4 , 6 ]).reshape (- 1 , 1 )
553
554
X_res_both = X_array
554
555
555
- # default passthrough
556
- ct = ColumnTransformer ([('trans ' , Trans (), [0 ])])
557
- assert_array_equal (ct .fit_transform (X_array ), X_res_both )
558
- assert_array_equal (ct .fit (X_array ).transform (X_array ), X_res_both )
556
+ # default drop
557
+ ct = ColumnTransformer ([('trans1 ' , Trans (), [0 ])])
558
+ assert_array_equal (ct .fit_transform (X_array ), X_res_first )
559
+ assert_array_equal (ct .fit (X_array ).transform (X_array ), X_res_first )
559
560
assert len (ct .transformers_ ) == 2
560
561
assert ct .transformers_ [- 1 ][0 ] == 'remainder'
561
- assert ct .transformers_ [- 1 ][1 ] == 'passthrough '
562
+ assert ct .transformers_ [- 1 ][1 ] == 'drop '
562
563
assert_array_equal (ct .transformers_ [- 1 ][2 ], [1 ])
563
564
564
- # specify to drop remaining columns
565
- ct = ColumnTransformer ([('trans1' , Trans (), [0 ])],
566
- remainder = 'drop' )
567
- assert_array_equal (ct .fit_transform (X_array ), X_res_first )
568
- assert_array_equal (ct .fit (X_array ).transform (X_array ), X_res_first )
565
+ # specify passthrough
566
+ ct = ColumnTransformer ([('trans' , Trans (), [0 ])], remainder = 'passthrough' )
567
+ assert_array_equal (ct .fit_transform (X_array ), X_res_both )
568
+ assert_array_equal (ct .fit (X_array ).transform (X_array ), X_res_both )
569
569
assert len (ct .transformers_ ) == 2
570
570
assert ct .transformers_ [- 1 ][0 ] == 'remainder'
571
- assert ct .transformers_ [- 1 ][1 ] == 'drop '
571
+ assert ct .transformers_ [- 1 ][1 ] == 'passthrough '
572
572
assert_array_equal (ct .transformers_ [- 1 ][2 ], [1 ])
573
573
574
574
# column order is not preserved (passed through added to end)
@@ -602,6 +602,9 @@ def test_column_transformer_remainder():
602
602
"remainder keyword needs to be one of \' drop\' , \' passthrough\' , "
603
603
"or estimator." , ct .fit_transform , X_array )
604
604
605
+ # check default for make_column_transformer
606
+ ct = make_column_transformer (([0 ], Trans ()))
607
+ assert ct .remainder == 'drop'
605
608
606
609
@pytest .mark .parametrize ("key" , [[0 ], np .array ([0 ]), slice (0 , 1 ),
607
610
np .array ([True , False ])])
0 commit comments