pandas.core.window.Rolling.count

Rolling.count() [source]

The rolling count of any non-NaN observations inside the window.

Returns:
Series or DataFrame

Returned object type is determined by the caller of the rolling calculation.

See also

pandas.Series.rolling
Calling object with Series data.
pandas.DataFrame.rolling
Calling object with DataFrames.
pandas.DataFrame.count
Count of the full DataFrame.

Examples

>>> s = pd.Series([2, 3, np.nan, 10])
>>> s.rolling(2).count()
0    1.0
1    2.0
2    1.0
3    1.0
dtype: float64
>>> s.rolling(3).count()
0    1.0
1    2.0
2    2.0
3    2.0
dtype: float64
>>> s.rolling(4).count()
0    1.0
1    2.0
2    2.0
3    3.0
dtype: float64

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.core.window.Rolling.count.html