Skip to main contentSkip to solution

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.

Keyboard Shortcuts

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