S_id Physics Chemistry Maths 1 67 45 87 2 58 65 76 3 59 47 69 4 66 79 71
From the table given above, a DataFrame 'df' is created. What will be the query to fetch maximum marks in chemistry?
| S_id | Physics | Chemistry | Maths |
|---|---|---|---|
| 1 | 67 | 45 | 87 |
| 2 | 58 | 65 | 76 |
| 3 | 59 | 47 | 69 |
| 4 | 66 | 79 | 71 |
From the table given above, a DataFrame 'df' is created. What will be the query to fetch maximum marks in chemistry?
Solution
✅ Correct Option: 3
df['Chemistry'] selects the Chemistry column as a Series, and .max() returns the largest value in it. Here the values are 45, 65, 47 and 79, so the result is 79.
Option 1: a DataFrame has no access attribute.
Option 2: max is a method, so it must be called as max(). Writing df.max['Chemistry'] tries to index the method itself and raises an error.
Option 4: iloc selects by integer position, not by label, so 'Chemistry' is not valid. Use loc for labels.
Related questions:
2026: 18 May Shift 2
2025: 15 May Shift 2