Pandas - check if ALL values are NaN in Series

Boosted_d16 picture Boosted_d16 · Oct 15, 2015 · Viewed 45.1k times · Source

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?

Answer

Andrew Rosenfeld picture Andrew Rosenfeld · Oct 15, 2015

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

mys.isnull().all()