•
Step 1: Understanding the Question:
The question asks for the built-in Pandas DataFrame function that calculates quartiles (or general quantiles) of numerical columns in a DataFrame.
•
Step 2: Key Formula or Approach:
A quartile divides data into four equal parts (25th, 50th, and 75th percentiles).
Pandas provides the quantile() function, which computes the values at the given quantile(s) over a specified axis.
To find quartiles, we can pass a list of values like [0.25, 0.5, 0.75] to the quantile() method.
•
Step 3: Detailed Explanation:
Let's examine the options:
- df.quartile(): Though intuitive, there is no function called quartile() in Pandas.
- df.pivot(): This method is used to reshape the DataFrame based on column values (pivoting), not for statistical summaries.
- df.quantile(): This is the correct function. By default, df.quantile(0.5) returns the median (50th percentile). To get the first, second, and third quartiles, we can execute df.quantile([0.25, 0.5, 0.75]).
- df.qt(): This is not a valid Pandas method.
Therefore, option (C) is the correct answer.
•
Step 4: Final Answer:
The correct option is (C).