pandas.core.window.rolling.Rolling.count#
- Rolling.count(numeric_only=False)[源代码]#
计算非 NaN 观测值的滚动计数。
- Parameters:
- numeric_onlybool,默认 False
仅包括浮点数、整数、布尔列。
在 1.5.0 版本加入.
- Returns:
- Series 或 DataFrame
返回类型与原始对象相同,并具有
np.float64数据类型。
参见
pandas.Series.rolling使用 Series 数据调用滚动。
pandas.DataFrame.rolling使用 DataFrame 调用滚动。
pandas.Series.countSeries 的聚合计数。
pandas.DataFrame.countDataFrame 的聚合计数。
Examples
>>> s = pd.Series([2, 3, np.nan, 10]) >>> s.rolling(2).count() 0 NaN 1 2.0 2 1.0 3 1.0 dtype: float64 >>> s.rolling(3).count() 0 NaN 1 NaN 2 2.0 3 2.0 dtype: float64 >>> s.rolling(4).count() 0 NaN 1 NaN 2 NaN 3 3.0 dtype: float64