6
df.isnull().any().any()

This line evaluates to a boolean True/False, as it checks whether a Pandas dataframe contains any NaN's in its rows or columns. Is there a more concise/idiomatic way of checking this?

emesday
  • 6,078
  • 3
  • 29
  • 46
maxm
  • 5,161
  • 7
  • 30
  • 33

1 Answers1

4

I think it's to use numpy's any:

In [11]: df = pd.DataFrame([[1, 2], [3, np.nan]])

In [12]: df.isnull().any().any()
Out[12]: True

In [13]: np.any(df.isnull())
Out[13]: True
Andy Hayden
  • 359,921
  • 101
  • 625
  • 535