Which of the following is used to drop the row having NaN value?
Which of the following is used to drop the row having NaN value?
Solution
✅ Correct Option: 2
df.dropna() removes rows that contain NaN (missing) values from a pandas DataFrame. By default it uses axis=0, so it drops rows. Passing axis=1 drops columns instead.
Option 3: df.drop() removes rows or columns by label or index, not by checking for NaN.
Options 1 and 4: loc[] and iloc[] only select data by label or position, and do not remove anything.
Related questions:
2025: 14 May Shift 1
2026: 21 May Shift 1
2025: 21 May Shift 1
2025: 21 May Shift 1