Considering s1 = pd.Series([2,3,np.nan,7, np.nan,9,11])
What will be the output of the following statement?
s1.dropna().tail(4)
Considering s1 = pd.Series([2,3,np.nan,7, np.nan,9,11])
What will be the output of the following statement?
s1.dropna().tail(4)
Solution
✅ Correct Option: 2
dropna() removes the NaN values and returns , with the original index labels 0, 1, 3, 5, 6 kept. tail(4) then returns the last 4 of these values: 3, 7, 9, 11, with index labels 1, 3, 5, 6.
Option 1: this ignores dropna(), which removes every NaN.
Option 4: this is what head(4) would give, not tail(4).
Pandas stores these values as floats because the original Series contains NaN, so the printed values appear as 3.0, 7.0, 9.0, 11.0.
Related questions:
2026: 23 May Shift 2
2025: 30 May Shift 2
2026: 21 May Shift 1