【数据挖掘】数据清洗——空缺值全局替换代码实现
作者:互联网
# -*- coding = utf-8 -*-
# @Time : 2021/11/27 12:16
# @Author : NKY
# @File : repalce.py
# @Sofeware : PyCharm
import numpy as np
from sklearn.impute import SimpleImputer
import pandas as pd
# data_url = "diabetes.csv"
# df = pd.read_csv(data_url)
imp = SimpleImputer(missing_values=np.nan,strategy='mean')
imp.fit([[1,2],[np.nan,3],[7,6]])
# imp.fit(df)
X = [[np.nan,2],[6,np.nan],[7,6]]
# print(imp.transform(df))
print(imp.transform(X))
标签:df,nan,imp,np,空缺,数据挖掘,import,清洗,SimpleImputer 来源: https://blog.csdn.net/weixin_44044395/article/details/121575340