11import sys
22import contextlib
33
4- from tqdm import tqdm
54import pandas as pd
65import numpy as np
76from scipy import sparse
109from .cross_validation import DataWrapper
1110from .pipeline import make_transformer_pipeline , _call_fit , TransformerPipeline
1211
13- PY3 = sys .version_info [0 ] == 3
14- if PY3 :
15- string_types = text_type = str
16- else :
17- string_types = basestring # noqa
18- text_type = unicode # noqa
12+ string_types = text_type = str
1913
2014
2115def _handle_feature (fea ):
@@ -70,7 +64,7 @@ class DataFrameMapper(BaseEstimator, TransformerMixin):
7064 """
7165
7266 def __init__ (self , features , default = False , sparse = False , df_out = False ,
73- input_df = False , show_progressbar = False ):
67+ input_df = False ):
7468 """
7569 Params:
7670
@@ -103,8 +97,6 @@ def __init__(self, features, default=False, sparse=False, df_out=False,
10397 as a pandas DataFrame or Series. Otherwise pass them as a
10498 numpy array. Defaults to ``False``.
10599
106- show_progressbar if ``True`` a progress bar will be shown during fit
107- and transform method. Defaults to ``False``
108100 """
109101 self .features = features
110102 self .built_features = None
@@ -114,7 +106,6 @@ def __init__(self, features, default=False, sparse=False, df_out=False,
114106 self .df_out = df_out
115107 self .input_df = input_df
116108 self .transformed_names_ = []
117- self .show_progressbar = show_progressbar
118109
119110 if (df_out and (sparse or default )):
120111 raise ValueError ("Can not use df_out with sparse or default" )
@@ -166,7 +157,6 @@ def __setstate__(self, state):
166157 self .built_features = state .get ('built_features' , self .features )
167158 self .built_default = state .get ('built_default' , self .default )
168159 self .transformed_names_ = state .get ('transformed_names_' , [])
169- self .show_progressbar = state .get ('show_progressbar' , False )
170160
171161 def _get_col_subset (self , X , cols , input_df = False ):
172162 """
@@ -215,9 +205,7 @@ def fit(self, X, y=None):
215205
216206 """
217207 self ._build ()
218- pbar = tqdm (self .built_features , disable = not self .show_progressbar )
219- for columns , transformers , options in pbar :
220- pbar .set_description ("[Fit] %s" % columns )
208+ for columns , transformers , options in self .built_features :
221209 input_df = options .get ('input_df' , self .input_df )
222210
223211 if transformers is not None :
@@ -306,9 +294,7 @@ def _transform(self, X, y=None, do_fit=False):
306294
307295 extracted = []
308296 self .transformed_names_ = []
309- pbar = tqdm (self .built_features , disable = not self .show_progressbar )
310- for columns , transformers , options in pbar :
311- pbar .set_description ("[Transform] %s" % columns )
297+ for columns , transformers , options in self .built_features :
312298 input_df = options .get ('input_df' , self .input_df )
313299
314300 # columns could be a string or list of
0 commit comments