Home > Net >  After applying imputation np.nan values is still present
After applying imputation np.nan values is still present

Time:11-23

I have used SimpleImputer to change df but empty rows is still present. What did I do wrong?

from sklearn.impute import SimpleImputer 


imp = SimpleImputer(missing_values=np.nan,strategy='most_frequent')
imp.fit_transform(df)
msno.matrix(df)

Result

CodePudding user response:

fit_transform is not in place transformation, it returns transformed object

from sklearn.impute import SimpleImputer 


imp = SimpleImputer(missing_values=np.nan,strategy='most_frequent')
data_without_nans = imp.fit_transform(df)
  • Related