Explore Library
Code QuizIntermediate

Imputing Missing Values

Find why SimpleImputer raises an error on this column.

Codepython
import pandas as pd
from sklearn.impute import SimpleImputer

df = pd.DataFrame({'age': [25, None, 30, None, 40]})

imputer = SimpleImputer(strategy='mean')
df['age'] = imputer.fit_transform(df['age'])
print(df)

What is the bug in this imputation code?