📜  简单的 imputer python 代码示例

📅  最后修改于: 2022-03-11 14:45:43.997000             🧑  作者: Mango

代码示例1
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'])