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?

emeth
  • 5,952
  • 2
  • 28
  • 46
maxm
  • 4,865
  • 7
  • 28
  • 32

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
  • 328,850
  • 93
  • 598
  • 514