Skip to main contentSkip to solution

Consider the following DataFrame 'dfSubject'.

MathsScienceS.StHindiEng
02221182021
12120172224
21419152423
32017222419
42315212515
52218192313
62319201522
72422241721
81225192123
91522252222
101821252423
111718202520

Select the correct command to find First and Third quartiles of all the subjects.

Solution

✅ Correct Option: 3

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.

Keyboard Shortcuts

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