To find the total number of NaN in the whole dataset, one can use _____________.
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().
Related questions:
2026: 26 May Shift 1