pandas.api.typing.Expanding.quantile#
- Expanding.quantile(q, interpolation='linear', numeric_only=False)[source]#
Calculate the expanding quantile.
At each step the specified quantile is computed from all prior observations, using the given interpolation method for values between data points.
- Parameters:
- qfloat
Quantile to compute. 0 <= quantile <= 1.
- interpolation{‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j:
linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.
lower: i.
higher: j.
nearest: i or j whichever is nearest.
midpoint: (i + j) / 2.
- numeric_onlybool, default False
Include only float, int, boolean columns.
- Returns:
- Series or DataFrame
Return type is the same as the original object with
np.float64dtype.
See also
Series.expandingCalling expanding with Series data.
DataFrame.expandingCalling expanding with DataFrames.
Series.quantileAggregating quantile for Series.
DataFrame.quantileAggregating quantile for DataFrame.
Examples
>>> ser = pd.Series([1, 2, 3, 4, 5, 6], index=["a", "b", "c", "d", "e", "f"]) >>> ser.expanding(min_periods=4).quantile(0.25) a NaN b NaN c NaN d 1.75 e 2.00 f 2.25 dtype: float64