Skip to content

Commit 09c416c

Browse files
WillAydjreback
authored andcommitted
DOC: Updated kurt docstring (for pandas sprint) (pandas-dev#19999)
1 parent ad15f80 commit 09c416c

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

pandas/core/window.py

+47-3
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,53 @@ def skew(self, **kwargs):
899899
return self._apply('roll_skew', 'skew',
900900
check_minp=_require_min_periods(3), **kwargs)
901901

902-
_shared_docs['kurt'] = """Unbiased %(name)s kurtosis"""
902+
_shared_docs['kurt'] = dedent("""
903+
Calculate unbiased %(name)s kurtosis.
904+
905+
This function uses Fisher's definition of kurtosis without bias.
906+
907+
Parameters
908+
----------
909+
kwargs : Under Review
910+
911+
Returns
912+
-------
913+
Series or DataFrame (matches input)
914+
Like-indexed object containing the result of function application
915+
916+
See Also
917+
--------
918+
pandas.Series.%(name)s
919+
pandas.DataFrame.%(name)s
920+
pandas.Series.kurtosis
921+
pandas.DataFrame.kurtosis
922+
scipy.stats.skew
923+
scipy.stats.kurtosis
924+
925+
Notes
926+
-----
927+
A minimum of 4 periods is required for the rolling calculation.
928+
929+
Examples
930+
--------
931+
The below example will show a rolling calculation with a window size of
932+
four matching the equivalent function call using `scipy.stats`.
933+
934+
>>> arr = [1, 2, 3, 4, 999]
935+
>>> import scipy.stats
936+
>>> print("{0:.6f}".format(scipy.stats.kurtosis(arr[:-1], bias=False)))
937+
-1.200000
938+
>>> print("{0:.6f}".format(scipy.stats.kurtosis(arr[1:], bias=False)))
939+
3.999946
940+
>>> df = pd.DataFrame(arr)
941+
>>> df.rolling(4).kurt()
942+
0
943+
0 NaN
944+
1 NaN
945+
2 NaN
946+
3 -1.200000
947+
4 3.999946
948+
""")
903949

904950
def kurt(self, **kwargs):
905951
return self._apply('roll_kurt', 'kurt',
@@ -1221,7 +1267,6 @@ def skew(self, **kwargs):
12211267
return super(Rolling, self).skew(**kwargs)
12221268

12231269
@Substitution(name='rolling')
1224-
@Appender(_doc_template)
12251270
@Appender(_shared_docs['kurt'])
12261271
def kurt(self, **kwargs):
12271272
return super(Rolling, self).kurt(**kwargs)
@@ -1461,7 +1506,6 @@ def skew(self, **kwargs):
14611506
return super(Expanding, self).skew(**kwargs)
14621507

14631508
@Substitution(name='expanding')
1464-
@Appender(_doc_template)
14651509
@Appender(_shared_docs['kurt'])
14661510
def kurt(self, **kwargs):
14671511
return super(Expanding, self).kurt(**kwargs)

0 commit comments

Comments
 (0)