pandas.Series.expanding#
- Series.expanding(min_periods=1, center=None, axis=0, method='single')[源代码]#
提供扩展窗口计算。
- 参数
- min_periods整型,默认值为1
窗口中需要具有值的最小观测数;否则,结果为
np.nan
。- center布尔值,默认为False
如果为False,则将窗口标签设置为窗口索引的右边缘。
如果为True,则将窗口标签设置为窗口索引的中心。
1.1.0 版后已移除.
- axisInt或str,默认为0
如果
0
或'index'
,在各行之间滚动。如果
1
或'columns'
,在柱子上滚动。- methodStr{‘Single’,‘TABLE’},默认为‘Single’
按单列或单行执行滚动操作 (
'single'
)或在整个对象上 ('table'
)。此参数仅在指定
engine='numba'
在方法调用中。1.3.0 新版功能.
- 退货
Expanding
子类
注意事项
看见 Windowing Operations 获取更多用法详细信息和示例。
示例
>>> df = pd.DataFrame({"B": [0, 1, 2, np.nan, 4]}) >>> df B 0 0.0 1 1.0 2 2.0 3 NaN 4 4.0
min_periods
计算值所需的1个观测值与3个观测值的扩展总和。
>>> df.expanding(1).sum() B 0 0.0 1 1.0 2 3.0 3 3.0 4 7.0 >>> df.expanding(3).sum() B 0 NaN 1 NaN 2 3.0 3 3.0 4 7.0