Consider the following DataFrame 'dfSubject'.
Maths Science S.St Hindi Eng 0 22 21 18 20 21 1 21 20 17 22 24 2 14 19 15 24 23 3 20 17 22 24 19 4 23 15 21 25 15 5 22 18 19 23 13 6 23 19 20 15 22 7 24 22 24 17 21 8 12 25 19 21 23 9 15 22 25 22 22 10 18 21 25 24 23 11 17 18 20 25 20
Select the correct command to find First and Third quartiles of all the subjects.
Consider the following DataFrame 'dfSubject'.
| Maths | Science | S.St | Hindi | Eng | |
|---|---|---|---|---|---|
| 0 | 22 | 21 | 18 | 20 | 21 |
| 1 | 21 | 20 | 17 | 22 | 24 |
| 2 | 14 | 19 | 15 | 24 | 23 |
| 3 | 20 | 17 | 22 | 24 | 19 |
| 4 | 23 | 15 | 21 | 25 | 15 |
| 5 | 22 | 18 | 19 | 23 | 13 |
| 6 | 23 | 19 | 20 | 15 | 22 |
| 7 | 24 | 22 | 24 | 17 | 21 |
| 8 | 12 | 25 | 19 | 21 | 23 |
| 9 | 15 | 22 | 25 | 22 | 22 |
| 10 | 18 | 21 | 25 | 24 | 23 |
| 11 | 17 | 18 | 20 | 25 | 20 |
Select the correct command to find First and Third quartiles of all the subjects.
Solution
DataFrame.quantile() takes a list of quantile values and returns them for every column. The first quartile is the 0.25 quantile and the third is the 0.75 quantile, so dfSubject.quantile([.25,.75]) returns exactly Q1 and Q3 for all subjects.
Option 2: also includes .50 (the median, or second quartile), so it returns more than the first and third quartiles asked for.
Options 1 and 4: groupby() is for grouping rows by a column, and quantiles is not a defined column. sum() adds values and does not compute quartiles.
Related questions:
2026: 21 May Shift 1
2026: 29 May Shift 2
2026: 18 May Shift 2
2026: 11 May Shift 2