Skip to main contentSkip to solution

Which of the following is used for label based indexing?

Solution

✅ Correct Option: 1

loc is the label-based indexer in pandas, and it is used with square brackets. DataFrame.loc['Math'] selects the row whose index label is 'Math'.


Option 2: DataFrame.loc['Math'] > 60 selects the row and then compares its values with 60, giving a True/False Series. The comparison is not the indexing.

Option 4: loc is an indexer, not a function, so round brackets loc('Math') raise an error.


We believe the answer could be Option 3 as well, since DataFrame.loc['Math':'Science'] is also valid label-based indexing (a label slice that includes both end labels). NCERT itself uses slices like ResultDF.loc['Maths':'Science'] as label-based indexing. However, NTA's final answer key (after all challenges) says Option 1.

Keyboard Shortcuts

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