1
1
import sys
2
2
import contextlib
3
3
4
- from tqdm import tqdm
5
4
import pandas as pd
6
5
import numpy as np
7
6
from scipy import sparse
10
9
from .cross_validation import DataWrapper
11
10
from .pipeline import make_transformer_pipeline , _call_fit , TransformerPipeline
12
11
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
19
13
20
14
21
15
def _handle_feature (fea ):
@@ -70,7 +64,7 @@ class DataFrameMapper(BaseEstimator, TransformerMixin):
70
64
"""
71
65
72
66
def __init__ (self , features , default = False , sparse = False , df_out = False ,
73
- input_df = False , show_progressbar = False ):
67
+ input_df = False ):
74
68
"""
75
69
Params:
76
70
@@ -103,8 +97,6 @@ def __init__(self, features, default=False, sparse=False, df_out=False,
103
97
as a pandas DataFrame or Series. Otherwise pass them as a
104
98
numpy array. Defaults to ``False``.
105
99
106
- show_progressbar if ``True`` a progress bar will be shown during fit
107
- and transform method. Defaults to ``False``
108
100
"""
109
101
self .features = features
110
102
self .built_features = None
@@ -114,7 +106,6 @@ def __init__(self, features, default=False, sparse=False, df_out=False,
114
106
self .df_out = df_out
115
107
self .input_df = input_df
116
108
self .transformed_names_ = []
117
- self .show_progressbar = show_progressbar
118
109
119
110
if (df_out and (sparse or default )):
120
111
raise ValueError ("Can not use df_out with sparse or default" )
@@ -166,7 +157,6 @@ def __setstate__(self, state):
166
157
self .built_features = state .get ('built_features' , self .features )
167
158
self .built_default = state .get ('built_default' , self .default )
168
159
self .transformed_names_ = state .get ('transformed_names_' , [])
169
- self .show_progressbar = state .get ('show_progressbar' , False )
170
160
171
161
def _get_col_subset (self , X , cols , input_df = False ):
172
162
"""
@@ -215,9 +205,7 @@ def fit(self, X, y=None):
215
205
216
206
"""
217
207
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 :
221
209
input_df = options .get ('input_df' , self .input_df )
222
210
223
211
if transformers is not None :
@@ -306,9 +294,7 @@ def _transform(self, X, y=None, do_fit=False):
306
294
307
295
extracted = []
308
296
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 :
312
298
input_df = options .get ('input_df' , self .input_df )
313
299
314
300
# columns could be a string or list of
0 commit comments