How can you get a NaN after impute?

Viewed 21

I am actually very confused with imputer. I am using SimpleImputer to impute data for the housing project.

# Visualizing some of the features
import matplotlib.pyplot as plt
from sklearn.impute import SimpleImputer
# Imputer
X_train_imputed = X_train.copy()
impute_numeric = SimpleImputer(strategy='mean')
impute_categorical = SimpleImputer(strategy='most_frequent')
X_train_imputed[numerical_cols] = pd.DataFrame(impute_numeric.fit_transform(X_train[numerical_cols]))
X_train_imputed[categorical_cols] = pd.DataFrame(impute_categorical.fit_transform(X_train[categorical_cols]))
# Indexing
X_train_imputed.index = X_train.index
# Feature columns
X_train_imputed.columns = X_train.columns
X_train_imputed.tail()

I am getting this output enter image description here

Not sure why there is a whole row with NaN when there was no such thing to begin with!

0 Answers
Related