Pandas Series.quantile() Function
Series.quantile() is a Pandas function used to calculate the quantiles of a Series. Quantiles are values that divide ordered data into equal parts; common ones include quartiles (25%, 50%, 75%) and the median (50%).
Quantiles are important measures for describing data distribution, helping to understand the shape of the distribution and identify outliers. They are widely used in statistical analysis, score ranking, income analysis, and other scenarios.
Basic syntax and parameters
quantile() is a member function of the Series object and is called directly with the dot operator.
Syntax format
Series.quantile(q=0.5, interpolation='linear', numeric_only=True, closed='both')
Parameter Description
| Parameters | Type | Description | Default value |
|---|---|---|---|
| q | float or array-like | Quantile value, ranging from 0 to 1. It can be a single value or a list of values. | 0.5 |
| interpolation | str | Interpolation method used when the quantile lies between two values. Options: 'linear', 'lower', 'higher', 'nearest', 'midpoint'. | 'linear' |
| numeric_only | bool | If True, only numeric data is calculated. | True |
| closed | str | Used in DataFrame to determine which side of the interval is closed; not commonly used in Series. | 'both' |
Common Pandas functions