Which function is used to get the quartiles from a dataframe 'df'?
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.
Related questions:
2026: 29 May Shift 1
2025: 27 May Shift 2