Skip to main contentSkip to solution

To find the total number of NaN in the whole dataset, one can use _____________.

Solution

✅ Correct Option: 1

df.isnull() returns a DataFrame of True/False values, with True wherever a value is NaN. The first sum() adds the True values (counted as 1) in each column and returns a Series of per-column counts. The second sum() adds those counts to give the total number of NaN in the whole dataset.


Option 2: stops after one sum(), so it gives NaN counts column by column, not the overall total.

Options 3 and 4: a pandas DataFrame has no isnan() method. isnan() belongs to NumPy (np.isnan). In pandas, use isnull() or isna().

Keyboard Shortcuts

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