- API reference
- Series
- pandas.Serie...
pandas.Series.quantile#
- Series.quantile(q=0.5,interpolation='linear')[source]#
Return value at the given quantile.
- Parameters:
- qfloat or array-like, default 0.5 (50% quantile)
The quantile(s) to compute, which can lie in range: 0 <= q <= 1.
- interpolation{‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
This optional parameter specifies the interpolation method to use,when the desired quantile lies between two data pointsi andj:
linear:i + (j - i) * (x-i)/(j-i), where(x-i)/(j-i) isthe fractional part of the index surrounded byi > j.
lower:i.
higher:j.
nearest:i orj whichever is nearest.
midpoint: (i +j) / 2.
- Returns:
- float or Series
If
q
is an array, a Series will be returned where theindex isq
and the values are the quantiles, otherwisea float will be returned.
See also
core.window.Rolling.quantile
Calculate the rolling quantile.
numpy.percentile
Returns the q-th percentile(s) of the array elements.
Examples
>>>s=pd.Series([1,2,3,4])>>>s.quantile(.5)2.5>>>s.quantile([.25,.5,.75])0.25 1.750.50 2.500.75 3.25dtype: float64
On this page