python数据可视化1

数据清理:

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all' #显示cell中的所有结果
athlete.isnull().any() #检查数据集中每列是否有缺失值

any():有一个就返回true

all():全部都是才返回true

填补缺失值:

连续型缺失值可以用平均值填补,离散型具体分析,本案例为奖牌分析,用未获奖牌来填补。

athlete['Height'] = athlete['Height'].fillna(athlete['Height'].mean())
athlete['Age'] = athlete['Age'].fillna(athlete['Age'].notnull())
athlete['Medal'] = athlete['Medal'].fillna('NoMedal')

再次验证:

athlete.isnull().any() #检查数据集中每列是否有缺失值
原文地址:https://www.cnblogs.com/xrj-/p/14455009.html