Skip to main contentSkip to solution

What does the df.isnull().sum() function do in Pandas?

Solution

✅ Correct Option: 1

df.isnull() returns a DataFrame of the same shape with True wherever a value is NaN. Calling .sum() on it adds up the True values (counted as 1) down each column, so the result is the count of NaN values in every column (attribute).


Option 3: that describes df.isnull().any(), which only tells whether a column has at least one NaN, not how many.

Options 2 and 4: filling values is done by fillna(), for example df.fillna(df.mean()) or df.fillna(0). isnull() never changes the data.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question