Which of the following is used for label based indexing?
Which of the following is used for label based indexing?
Solution
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.
Related questions:
2026: 21 May Shift 1
2026: 29 May Shift 2
2026: 21 May Shift 1