0
$\begingroup$

I have used SimpleImputer() to fill the missing values

my_imputer = SimpleImputer()
data_with_imputed_values = my_imputer.fit_transform(train_data)

what I expect is that my dataframe is filled with the mean of that column for the missing cells. yet it only works for one column and doesnt work for the other one.

To explain better the problem, here is the number of missing values before imputation

enter image description here

then here is the result after imputation enter image description here

why does it only work for column-Embarked but not for age?

$\endgroup$

1 Answer 1

2
$\begingroup$

In the second cell you are printing the isnull() on train_data... But you have applied imputer on train_data and assigned values to data_with_imputed_values... Try replacing train_data in the second cell with data_with_imputed_values.

missing_val_count_by_column = (data_with_imputed_values.isnull().sum())
missing_val_count_by_column
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.