Pandas - check if ALL values are NaN in Series Pandas - check if ALL values are NaN in Series python python

Pandas - check if ALL values are NaN in Series


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

mys.isnull().all()


This will check for all columns..

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


if df['col'].count() > 0:    then ...

This works well but I think it might be quite a slow approach. I made the mistake of embedding this into a 6000-times loop to test four columns - and it's brutal, but I can blame the programmer clearly :)

Obviously, don't be like me. Always: Test your columns for all-null once, set a variable with the yes - "empty" or no - "not empty" result - and then loop.