# Appending the response variable to the mapper
feature_type_tuple_list.append(('target', None))
# Passing the feature and the associated transformations to the dataframe mapper
jobs_mapper = DataFrameMapper(feature_type_tuple_list)
# Fit the mapper
jobs_mapper.fit_transform(df[features+['target']])
Its returningthe following errror.
Traceback (most recent call last):
File "/Users/jibybabu/Library/Python/2.7/lib/python/site-packages/IPython/core/interactiveshell.py", line 2869, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-63-39ac36018d2e>", line 1, in <module>
jobs_mapper.fit_transform(df[features+['target']])
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 455, in fit_transform
return self.fit(X, **fit_params).transform(X)
File "/usr/local/lib/python2.7/site-packages/sklearn_pandas/dataframe_mapper.py", line 97, in fit
transformers.fit(self._get_col_subset(X, columns))
File "/usr/local/lib/python2.7/site-packages/sklearn_pandas/pipeline.py", line 49, in fit
Xt, fit_params = self._pre_transform(X, **fit_params)
File "/usr/local/lib/python2.7/site-packages/sklearn_pandas/pipeline.py", line 42, in _pre_transform
Xt = transform.fit_transform(Xt, **fit_params_steps[name])
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 455, in fit_transform
return self.fit(X, **fit_params).transform(X)
File "/Library/Python/2.7/site-packages/sklearn/preprocessing/imputation.py", line 156, in fit
force_all_finite=False)
File "/Library/Python/2.7/site-packages/sklearn/utils/validation.py", line 373, in check_array
array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: could not convert string to float: california
Any idea what is the right way to do it?
Thanks,
Jiby
More specially, for categorical variables, I want to do label encoder and impute with mode, if the value is missing