Skip to content

Commit

Permalink
DOC" update the Pandas core window rolling count docstring" (#20264)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-stone authored and jorisvandenbossche committed Mar 19, 2018
1 parent c726c12 commit bd8a3cf
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,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 @@ -1451,7 +1486,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 @@ -1715,7 +1749,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

0 comments on commit bd8a3cf

Please sign in to comment.