Skip to content

Commit

Permalink
DOC: pd.core.window.Expanding.kurt docstring (split from pd.core.Roll…
Browse files Browse the repository at this point in the history
…ing.kurt) (#20064)
  • Loading branch information
toobaz authored and jorisvandenbossche committed Mar 11, 2018
1 parent b3d6ce6 commit c791a84
Showing 1 changed file with 51 additions and 22 deletions.
73 changes: 51 additions & 22 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,28 +926,7 @@ def skew(self, **kwargs):
Notes
-----
A minimum of 4 periods is required for the rolling calculation.
Examples
--------
The below example will show a rolling calculation with a window size of
four matching the equivalent function call using `scipy.stats`.
>>> arr = [1, 2, 3, 4, 999]
>>> fmt = "{0:.6f}" # limit the printed precision to 6 digits
>>> import scipy.stats
>>> print(fmt.format(scipy.stats.kurtosis(arr[:-1], bias=False)))
-1.200000
>>> print(fmt.format(scipy.stats.kurtosis(arr[1:], bias=False)))
3.999946
>>> s = pd.Series(arr)
>>> s.rolling(4).kurt()
0 NaN
1 NaN
2 NaN
3 -1.200000
4 3.999946
dtype: float64
A minimum of 4 periods is required for the %(name)s calculation.
""")

def kurt(self, **kwargs):
Expand Down Expand Up @@ -1269,6 +1248,31 @@ def var(self, ddof=1, *args, **kwargs):
def skew(self, **kwargs):
return super(Rolling, self).skew(**kwargs)

_agg_doc = dedent("""
Examples
--------
The example below will show a rolling calculation with a window size of
four matching the equivalent function call using `scipy.stats`.
>>> arr = [1, 2, 3, 4, 999]
>>> fmt = "{0:.6f}" # limit the printed precision to 6 digits
>>> import scipy.stats
>>> print(fmt.format(scipy.stats.kurtosis(arr[:-1], bias=False)))
-1.200000
>>> print(fmt.format(scipy.stats.kurtosis(arr[1:], bias=False)))
3.999946
>>> s = pd.Series(arr)
>>> s.rolling(4).kurt()
0 NaN
1 NaN
2 NaN
3 -1.200000
4 3.999946
dtype: float64
""")

@Appender(_agg_doc)
@Substitution(name='rolling')
@Appender(_shared_docs['kurt'])
def kurt(self, **kwargs):
Expand Down Expand Up @@ -1508,6 +1512,31 @@ def var(self, ddof=1, *args, **kwargs):
def skew(self, **kwargs):
return super(Expanding, self).skew(**kwargs)

_agg_doc = dedent("""
Examples
--------
The example below will show an expanding calculation with a window size of
four matching the equivalent function call using `scipy.stats`.
>>> arr = [1, 2, 3, 4, 999]
>>> import scipy.stats
>>> fmt = "{0:.6f}" # limit the printed precision to 6 digits
>>> print(fmt.format(scipy.stats.kurtosis(arr[:-1], bias=False)))
-1.200000
>>> print(fmt.format(scipy.stats.kurtosis(arr, bias=False)))
4.999874
>>> s = pd.Series(arr)
>>> s.expanding(4).kurt()
0 NaN
1 NaN
2 NaN
3 -1.200000
4 4.999874
dtype: float64
""")

@Appender(_agg_doc)
@Substitution(name='expanding')
@Appender(_shared_docs['kurt'])
def kurt(self, **kwargs):
Expand Down

0 comments on commit c791a84

Please sign in to comment.