Pandas Series: quantile() function
Value at the given quantile
The quantile() function is used to get value at the given quantile.
Syntax:
Series.quantile(self, q=0.5, interpolation='linear')
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
q | 0 <= q <= 1, the quantile(s) to compute. | float or array-like Default Value: 0.5 (50% quantile) |
Required |
interpolation | This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j:
|
{‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’} | Required |
Returns: float or Series
If q is an array, a Series will be returned where the index is q and the values are the quantiles, otherwise a float will be returned.
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
s = pd.Series([2, 3, 4, 5])
s.quantile(.5)
Output:
3.5
Python-Pandas Code:
import numpy as np
import pandas as pd
s = pd.Series([2, 3, 4, 5])
s.quantile([.15, .5, .55])
Output:
0.15 2.45 0.50 3.50 0.55 3.65 dtype: float64
Previous: Product of the values for the requested Pandas axis
Next: Compute numerical data ranks along axis
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics