Skip to main contentSkip to solution

Consider the following DataFrame 'df':

NameTestEnglishMathsHindiScience
Sumit167877588
Sumit276787282
Jyoti177836087
Jyoti269896865
Nidhi156786569
Nidhi267868991

Which statement results in marks secured by Jyoti in each subject in each test?

Solution

✅ Correct Option: 2

df['Name']=='Jyoti' gives a Boolean Series, True for rows where Name is Jyoti. Passing it inside df[...] selects only those rows with all their columns. So df[df['Name']=='Jyoti'] returns both of Jyoti's test rows, showing her marks in every subject for each test.


Option 1: the brackets are unbalanced, so it is a syntax error. It also never filters the DataFrame.

Option 3: df.loc['Name'] looks for a row labelled 'Name', not a column, so it raises a KeyError.

Option 4: ['Name']=='Jyoti' compares a plain list with a string, which gives the single value False, not a Boolean Series, so no rows are selected correctly.

Keyboard Shortcuts

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