【数据挖掘】数据清洗——空缺值全局替换代码实现

# -*- 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))
上一篇:Pandas图形绘制


下一篇:香港酒店数据分析