pandas.core.window.rolling.Rolling.quantile#
- Rolling.quantile(quantile, interpolation='linear', **kwargs)[源代码]#
计算滚动分位数。
- 参数
- quantile浮动
要计算的分位数。0<=分位数<=1。
- interpolation{‘线性’,‘较低’,‘较高’,‘中点’,‘最近’}
此可选参数指定当所需分位数位于两个数据点之间时要使用的内插方法 i 和 j :
线性: i + (j - i) * fraction ,在哪里 fraction 是索引的小数部分,由 i 和 j 。
较低: i 。
更高: j 。
最近: i 或 j 以最近者为准。
中点: (i + j )/2.
- **kwargs
对于NumPy兼容性,不会对结果产生影响。
- 退货
- 系列或DataFrame
返回类型与原始对象相同,
np.float64
数据类型。
参见
pandas.Series.rolling
使用系列数据进行呼叫滚动。
pandas.DataFrame.rolling
使用DataFrames调用滚动。
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