Skip to main contentSkip to solution

Which function is used to get the quartiles from a dataframe 'df'?

Solution

✅ Correct Option: 3

The pandas function df.quantile() returns values at given quantiles. Quartiles are the 0.25, 0.5 and 0.75 quantiles, so df.quantile([0.25, 0.5, 0.75]) gives Q1, Q2 (median) and Q3 for each numeric column.


Option 1: there is no quartile() method in pandas. Quartiles are obtained through quantile().

Option 2: pivot() reshapes a dataframe and does not compute statistics.

Option 4: qt() is not a pandas method.

By default df.quantile() uses q = 0.5, which returns the median.

Keyboard Shortcuts

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