Pandas - check if ALL values are NaN in Series

无人久伴 提交于 2019-12-09 07:26:49

问题


I have a data series which looks like this:

print mys

id_L1
2       NaN
3       NaN
4       NaN
5       NaN
6       NaN
7       NaN
8       NaN

I would like to check is all the values are NaN.

My attempt:

pd.isnull(mys).all()

Output:

True

Is this the correct way to do it?


回答1:


Yes, that's correct, but I think a more idiomatic way would be:

mys.isnull().all()



回答2:


This will check for all columns..

mys.isnull().values.all(axis=0)


来源:https://stackoverflow.com/questions/33147158/pandas-check-if-all-values-are-nan-in-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!