To find the number of missing values in the whole DataFrame 'df', which of the following statements is correct?
A. df.isna().sum().sum()
B. df.isnull.sum()
C. df.isnull.sum().sum()
D. df.isna.sum()
To find the number of missing values in the whole DataFrame 'df', which of the following statements is correct?
A. df.isna().sum().sum()
B. df.isnull.sum()
C. df.isnull.sum().sum()
D. df.isna.sum()
Solution
df.isna() (or its alias df.isnull()) returns a DataFrame of True/False values, with True wherever a value is missing. The first .sum() counts the True values in each column. The second .sum() adds those column counts into one number for the whole DataFrame.
NCERT uses exactly this chain, df.isnull().sum().sum(), to count all the NaN values in a DataFrame. So df.isna().sum().sum() gives the total number of missing values, and df.isnull().sum().sum() does the same because isnull is just another name for isna.
Options B and D: these give only a count per column, not one total for the whole DataFrame.
We believe the answer should be A alone, since in statement C isnull is written without parentheses, so it is a method reference and .sum() on it raises an AttributeError. No option lists A alone. However, NTA's final answer key (after all challenges) says Option 2.
Related questions:
2025: 16 May Shift 1
2026: 18 May Shift 2
2026: 19 May Shift 1