2018-12-18
阅读量:
781
pandas如何处理确实数据?
处理缺失数据
数据分析阶段还包括处理来自我们数据集的缺失数据的能力,在处理缺失的数据时,您作为数据分析师要么放弃包含NaN值的列(dropna方法),要么用整个列条目的均值或模式填充缺失的数据(fillna方法),这个决定是具有重要意义,取决于数据和影响会在我们的结果中产生。
- 删除丢失的数据:
考虑这是由以下代码生成的DataFrame:
import pandas as pd
# Create a DataFrame
dframe = pd.DataFrame({'Geeks': [23, 24, 22],
'For': [10, 12, np.nan],
'geeks': [0, np.nan, np.nan]},
columns =['Geeks', 'For', 'geeks'])
# This will remove all the
# rows with NAN values
# If axis is not defined then
# it is along rows i.e. axis = 0
dframe.dropna(inplace = True)
print(dframe)
# if axis is equal to 1
dframe.dropna(axis = 1, inplace = True)
print(dframe)
输出:






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论