Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC" update the Pandas core window rolling count docstring" #20264

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,43 @@ def calc(x):

class _Rolling_and_Expanding(_Rolling):

_shared_docs['count'] = """%(name)s count of number of non-NaN
observations inside provided window."""
_shared_docs['count'] = dedent(r"""
The %(name)s count of any non-NaN observations inside the window.

Returns
-------
Series or DataFrame
Returned object type is determined by the caller of the %(name)s
calculation.

See Also
--------
pandas.Series.%(name)s : Calling object with Series data
pandas.DataFrame.%(name)s : 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
""")

def count(self):

Expand Down Expand Up @@ -1199,7 +1234,6 @@ def aggregate(self, arg, *args, **kwargs):
agg = aggregate

@Substitution(name='rolling')
@Appender(_doc_template)
@Appender(_shared_docs['count'])
def count(self):

Expand Down Expand Up @@ -1443,7 +1477,6 @@ def aggregate(self, arg, *args, **kwargs):
agg = aggregate

@Substitution(name='expanding')
@Appender(_doc_template)
@Appender(_shared_docs['count'])
def count(self, **kwargs):
return super(Expanding, self).count(**kwargs)
Expand Down