如何在数据框的每一行中检查缺失值
我有一个带有100列和数百万行的数据框架,并想检查每个数据框架中的丢失值。
代码:
df.isna().sum()
目前,我正在使用上述代码进行分析,这可以帮助我每列中缺少值。 我们如何获得每行缺失值WRT。
同样,[行]列的分布图[缺失值的数量]。
I have a dataframe with 100's of columns and millions of rows and would like to check the missing values in each row of dataframe.
Code :
df.isna().sum()
Currently, i'm analzing with above code which helps me with missing values in each column.
How we can get the missing values w.r.t each row.
Also, distribution plot of [column of rows] vs [number of missing values].
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在列上尝试
sum
如果您是指每个列中缺少值的数量,则
df.isna()。sum()
已经给出结果。You can try
sum
on columnsIf you mean number of missing values in each columns,
df.isna().sum()
already gives the result.您可以在第一次尝试以下操作:
只要您就可以了解哪些列的NAN最多,并且可以绘制它,
您可以使用:
df.isna知道数据帧中NAN的%总数().mean()。均值()
,现在如果您想要每行Nan的%:
而不是使用打印,您可以将结果存储在数据框架中
You can try in a first time to do :
Just so you can you understand which columns has the most or the less NaN, and you can plot it
You can know the % total of Nan in your dataframe using :
df.isna().mean().mean()
And now if you want the % of NaN per line :
Instead of using a print you can store the result in a dataframe