Skip to main contentSkip to solution

A DataFrame ResultDF is created below:

ArnabRamitSamridhiRiyaMallika
Maths9092898194
Science9181917195
Hindi9796886799
Hindi9789786045

Identify the correct command to remove the duplicate row labelled ‘Hindi’.

Solution

✅ Correct Option: 3

In pandas, DataFrame.drop(labels, axis=0) removes rows by their index label. Here 'Hindi' is a row label, so ResultDF.drop('Hindi', axis=0) is the correct command.

Note that drop removes every row with that label, so both 'Hindi' rows are deleted, not just the duplicate.


Option 1: axis=1 refers to columns, and there is no column named 'Hindi', so it raises a KeyError.

Options 2 and 4: drop.Hindi and deleteduplicates.Hindi are not valid pandas syntax. The real duplicate-removal method is drop_duplicates(), and it is called with brackets.

Keyboard Shortcuts

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