pandas.core.window.rolling.Rolling.quantile #
- 滚动。分位数( q , interpolation = '线性' , numeric_only = False ) [来源] #
计算滚动分位数。
- 参数:
- 分位数浮点数
要计算的分位数。 0 <= 分位数 <= 1。
自 2.1.0 版起已弃用:在未来版本中将重命名为“q”。
- 插值{'线性', '较低', '较高', '中点', '最近'}
此可选参数指定当所需分位数位于两个数据点i和j之间时要使用的插值方法:
线性:i + (j - i) *fraction,其中fraction是由i和j包围的索引的小数部分。
下:我。
较高:j .
最近的:i或j,以最接近的为准。
中点:( i + j ) / 2。
- numeric_only布尔值,默认 False
仅包含 float、int、boolean 列。
1.5.0 版本中的新增内容。
- 返回:
- 系列或数据框
返回类型与具有 dtype 的原始对象相同
np.float64
。
也可以看看
pandas.Series.rolling
使用系列数据进行滚动调用。
pandas.DataFrame.rolling
使用 DataFrame 调用滚动。
pandas.Series.quantile
聚合系列的分位数。
pandas.DataFrame.quantile
聚合 DataFrame 的分位数。
例子
>>> s = pd.Series([1, 2, 3, 4]) >>> s.rolling(2).quantile(.4, interpolation='lower') 0 NaN 1 1.0 2 2.0 3 3.0 dtype: float64
>>> s.rolling(2).quantile(.4, interpolation='midpoint') 0 NaN 1 1.5 2 2.5 3 3.5 dtype: float64