Open
Description
When I use DataFrameMapper
and set up default=None
to transform a column, all other columns
types are changed to object
. But this does not happen when I have only float
and/or int
columns
import pandas as pd
import numpy as np
from sklearn_pandas import DataFrameMapper
from sklearn.impute import SimpleImputer
# all numerical columns lead to no error
da = pd.DataFrame({
'a':[1,3,np.nan],
'b': [1.2,2,3]})
print(da.dtypes)
aux_imp = DataFrameMapper([
(['a'], SimpleImputer(strategy='mean'))],
df_out=True, default=None)
da = aux_imp.fit_transform(da)
print(da.dtypes)
# if a column is of str it leads to errors
da = pd.DataFrame({
'a':[1,3,np.nan],
'b': [1.2,2,3],
'c':['c', 'c', 'a']
})
print(da.dtypes)
aux_imp = DataFrameMapper(
[(['a'], SimpleImputer(strategy='mean'))],
df_out=True, default=None)
da = aux_imp.fit_transform(da)
print(da.dtypes)