Skip to content

Commit fdcdcb8

Browse files
DOC: Enforce Numpy Docstring Validation for pandas.DataFrame.kurt and pandas.DataFrame.kurtosis (#58493)
DOC: fix ruff issues
1 parent c150511 commit fdcdcb8

File tree

2 files changed

+79
-3
lines changed

2 files changed

+79
-3
lines changed

ci/code_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
7373
-i "pandas.DataFrame.at_time PR01" \
74-
-i "pandas.DataFrame.kurt RT03,SA01" \
75-
-i "pandas.DataFrame.kurtosis RT03,SA01" \
7674
-i "pandas.DataFrame.max RT03" \
7775
-i "pandas.DataFrame.mean RT03,SA01" \
7876
-i "pandas.DataFrame.median RT03,SA01" \

pandas/core/frame.py

+79-1
Original file line numberDiff line numberDiff line change
@@ -12069,14 +12069,92 @@ def kurt(
1206912069
) -> Series | Any: ...
1207012070

1207112071
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="kurt")
12072-
@doc(make_doc("kurt", ndim=2))
1207312072
def kurt(
1207412073
self,
1207512074
axis: Axis | None = 0,
1207612075
skipna: bool = True,
1207712076
numeric_only: bool = False,
1207812077
**kwargs,
1207912078
) -> Series | Any:
12079+
"""
12080+
Return unbiased kurtosis over requested axis.
12081+
12082+
Kurtosis obtained using Fisher's definition of
12083+
kurtosis (kurtosis of normal == 0.0). Normalized by N-1.
12084+
12085+
Parameters
12086+
----------
12087+
axis : {index (0), columns (1)}
12088+
Axis for the function to be applied on.
12089+
For `Series` this parameter is unused and defaults to 0.
12090+
12091+
For DataFrames, specifying ``axis=None`` will apply the aggregation
12092+
across both axes.
12093+
12094+
.. versionadded:: 2.0.0
12095+
12096+
skipna : bool, default True
12097+
Exclude NA/null values when computing the result.
12098+
numeric_only : bool, default False
12099+
Include only float, int, boolean columns.
12100+
12101+
**kwargs
12102+
Additional keyword arguments to be passed to the function.
12103+
12104+
Returns
12105+
-------
12106+
Series or scalar
12107+
Unbiased kurtosis over requested axis.
12108+
12109+
See Also
12110+
--------
12111+
Dataframe.kurtosis : Returns unbiased kurtosis over requested axis.
12112+
12113+
Examples
12114+
--------
12115+
>>> s = pd.Series([1, 2, 2, 3], index=["cat", "dog", "dog", "mouse"])
12116+
>>> s
12117+
cat 1
12118+
dog 2
12119+
dog 2
12120+
mouse 3
12121+
dtype: int64
12122+
>>> s.kurt()
12123+
1.5
12124+
12125+
With a DataFrame
12126+
12127+
>>> df = pd.DataFrame(
12128+
... {"a": [1, 2, 2, 3], "b": [3, 4, 4, 4]},
12129+
... index=["cat", "dog", "dog", "mouse"],
12130+
... )
12131+
>>> df
12132+
a b
12133+
cat 1 3
12134+
dog 2 4
12135+
dog 2 4
12136+
mouse 3 4
12137+
>>> df.kurt()
12138+
a 1.5
12139+
b 4.0
12140+
dtype: float64
12141+
12142+
With axis=None
12143+
12144+
>>> df.kurt(axis=None).round(6)
12145+
-0.988693
12146+
12147+
Using axis=1
12148+
12149+
>>> df = pd.DataFrame(
12150+
... {"a": [1, 2], "b": [3, 4], "c": [3, 4], "d": [1, 2]},
12151+
... index=["cat", "dog"],
12152+
... )
12153+
>>> df.kurt(axis=1)
12154+
cat -6.0
12155+
dog -6.0
12156+
dtype: float64
12157+
"""
1208012158
result = super().kurt(
1208112159
axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
1208212160
)

0 commit comments

Comments
 (0)