Skip to content

Commit e7b87f7

Browse files
tommy-stoneAndrew Bui
authored and
Andrew Bui
committed
DOC" update the Pandas core window rolling count docstring" (pandas-dev#20264)
1 parent 98cebfd commit e7b87f7

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

pandas/core/window.py

+37-4
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,43 @@ def calc(x):
892892

893893
class _Rolling_and_Expanding(_Rolling):
894894

895-
_shared_docs['count'] = """%(name)s count of number of non-NaN
896-
observations inside provided window."""
895+
_shared_docs['count'] = dedent(r"""
896+
The %(name)s count of any non-NaN observations inside the window.
897+
898+
Returns
899+
-------
900+
Series or DataFrame
901+
Returned object type is determined by the caller of the %(name)s
902+
calculation.
903+
904+
See Also
905+
--------
906+
pandas.Series.%(name)s : Calling object with Series data
907+
pandas.DataFrame.%(name)s : Calling object with DataFrames
908+
pandas.DataFrame.count : Count of the full DataFrame
909+
910+
Examples
911+
--------
912+
>>> s = pd.Series([2, 3, np.nan, 10])
913+
>>> s.rolling(2).count()
914+
0 1.0
915+
1 2.0
916+
2 1.0
917+
3 1.0
918+
dtype: float64
919+
>>> s.rolling(3).count()
920+
0 1.0
921+
1 2.0
922+
2 2.0
923+
3 2.0
924+
dtype: float64
925+
>>> s.rolling(4).count()
926+
0 1.0
927+
1 2.0
928+
2 2.0
929+
3 3.0
930+
dtype: float64
931+
""")
897932

898933
def count(self):
899934

@@ -1451,7 +1486,6 @@ def aggregate(self, arg, *args, **kwargs):
14511486
agg = aggregate
14521487

14531488
@Substitution(name='rolling')
1454-
@Appender(_doc_template)
14551489
@Appender(_shared_docs['count'])
14561490
def count(self):
14571491

@@ -1715,7 +1749,6 @@ def aggregate(self, arg, *args, **kwargs):
17151749
agg = aggregate
17161750

17171751
@Substitution(name='expanding')
1718-
@Appender(_doc_template)
17191752
@Appender(_shared_docs['count'])
17201753
def count(self, **kwargs):
17211754
return super(Expanding, self).count(**kwargs)

0 commit comments

Comments
 (0)