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?
The official documentation for pandas defines what most developers would know as null values as missing or missing data in pandas. Within pandas, a missing value is denoted by NaN .
Call the isnull() function of the Series object. It returns a boolean Series of the same size. Each True value in this boolean Series indicates that the corresponding value in the Original Series (selected column) is NaN. Check if all values in the boolean Series are True or not.
By using isnull(). values. any() method you can check if a pandas DataFrame contains NaN / None values in any cell (all rows & columns ).
Yes, that's correct, but I think a more idiomatic way would be:
mys.isnull().all()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With