复杂的缺失值填补方法,会考虑到数据的整体情况,然后在对有缺失值的数据进行填充,本小节将会介绍3种复杂的缺失值填补方法。
数据准备
## 输出高清图像%config InlineBackend.figure_format = 'retina'%matplotlib inline## 图像显示中文的问题import matplotlibmatplotlib.rcParams['axes.unicode_minus']=Falseimport seaborn as sns sns.set(font= "Kaiti",style="ticks",font_scale=1.4)## 导入本小节会使用到的包import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as sns import missingno as msno from sklearn.impute import IterativeImputerfrom sklearn.impute import KNNImputerfrom missingpy import MissForest## 读取用于演示的数据集oceandf = pd.read_csv("data/chap2/热带大气海洋数据.csv")## 判断每个变量中是否存在缺失值pd.isna(oceandf).sum()Year 0Latitude 0Longitude 0SeaSurfaceTemp 3AirTemp 81Humidity 93