📅  最后修改于: 2022-03-11 14:45:43.997000             🧑  作者: Mango
from sklearn.impute import SimpleImputer
imputer = SimpleImputer(strategy='median')
# for the entire df
df = pd.DataFrame(imputer.fit_transform(df), columns=df.columns)
# for specific column
df['Embarked'] = pd.DataFrame(imputer.fit_transform(pd.DataFrame(df['Embarked'], columns=['Embarked'])), columns=['Embarked'])