pandas.core.resample.Resampler.quantile#

final Resampler.quantile(q=0.5, **kwargs)[源代码]#

在给定的分位数处返回值。

Parameters:
qfloat 或 array-like, 默认 0.5 (50% 分位数)
Returns:
DataFrame 或 Series

组内值的分位数。

参见

Series.quantile

返回值为 q 的 Series,其值为分位数。

DataFrame.quantile

返回值为分位数的 DataFrame,其列为 self 的列。

DataFrameGroupBy.quantile

返回值为其分位数的 DataFrame,其列为分组的列。

Examples

>>> ser = pd.Series([1, 3, 2, 4, 3, 8],
...                 index=pd.DatetimeIndex(['2023-01-01',
...                                         '2023-01-10',
...                                         '2023-01-15',
...                                         '2023-02-01',
...                                         '2023-02-10',
...                                         '2023-02-15']))
>>> ser.resample('MS').quantile()
2023-01-01    2.0
2023-02-01    4.0
Freq: MS, dtype: float64
>>> ser.resample('MS').quantile(.25)
2023-01-01    1.5
2023-02-01    3.5
Freq: MS, dtype: float64