'MICE implementation in python

I am trying to use MICE implementation using the following link:

Missing value imputation in python using KNN

from fancyimpute import MICE as MICE
df_complete=MICE().complete(df_train)

I am getting following error:

ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

On the link also, it says that they have replaced with NaN. I am not sure what does it mean? I have already tried: df_train.isnull(np.array([np.nan, 0], dtype=float)) but it is not helping either.



Solution 1:[1]

df_train_numeric = df_train[['Age']].select_dtypes(include=[np.float]).as_matrix()
df_complete=MICE().complete(df_train_numeric)

Thanks to Data imputation with fancyimpute and pandas

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 krishna