From 9b271ef0225a88642fe7a1d8d27450b2f9d02eb1 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Tue, 30 Apr 2024 18:31:50 +0530 Subject: [PATCH] DOC: fix ruff issues --- ci/code_checks.sh | 2 -- pandas/core/frame.py | 80 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 161047197ff6f..66f5a2f2afb98 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -72,8 +72,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \ -i "pandas.DataFrame.__dataframe__ SA01" \ -i "pandas.DataFrame.at_time PR01" \ - -i "pandas.DataFrame.kurt RT03,SA01" \ - -i "pandas.DataFrame.kurtosis RT03,SA01" \ -i "pandas.DataFrame.max RT03" \ -i "pandas.DataFrame.mean RT03,SA01" \ -i "pandas.DataFrame.median RT03,SA01" \ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 9fbbc2c08efaa..4b133e342b8c8 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -12064,7 +12064,6 @@ def kurt( ) -> Series | Any: ... @deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="kurt") - @doc(make_doc("kurt", ndim=2)) def kurt( self, axis: Axis | None = 0, @@ -12072,6 +12071,85 @@ def kurt( numeric_only: bool = False, **kwargs, ) -> Series | Any: + """ + Return unbiased kurtosis over requested axis. + + Kurtosis obtained using Fisher's definition of + kurtosis (kurtosis of normal == 0.0). Normalized by N-1. + + Parameters + ---------- + axis : {index (0), columns (1)} + Axis for the function to be applied on. + For `Series` this parameter is unused and defaults to 0. + + For DataFrames, specifying ``axis=None`` will apply the aggregation + across both axes. + + .. versionadded:: 2.0.0 + + skipna : bool, default True + Exclude NA/null values when computing the result. + numeric_only : bool, default False + Include only float, int, boolean columns. + + **kwargs + Additional keyword arguments to be passed to the function. + + Returns + ------- + Series or scalar + Unbiased kurtosis over requested axis. + + See Also + -------- + Dataframe.kurtosis : Returns unbiased kurtosis over requested axis. + + Examples + -------- + >>> s = pd.Series([1, 2, 2, 3], index=["cat", "dog", "dog", "mouse"]) + >>> s + cat 1 + dog 2 + dog 2 + mouse 3 + dtype: int64 + >>> s.kurt() + 1.5 + + With a DataFrame + + >>> df = pd.DataFrame( + ... {"a": [1, 2, 2, 3], "b": [3, 4, 4, 4]}, + ... index=["cat", "dog", "dog", "mouse"], + ... ) + >>> df + a b + cat 1 3 + dog 2 4 + dog 2 4 + mouse 3 4 + >>> df.kurt() + a 1.5 + b 4.0 + dtype: float64 + + With axis=None + + >>> df.kurt(axis=None).round(6) + -0.988693 + + Using axis=1 + + >>> df = pd.DataFrame( + ... {"a": [1, 2], "b": [3, 4], "c": [3, 4], "d": [1, 2]}, + ... index=["cat", "dog"], + ... ) + >>> df.kurt(axis=1) + cat -6.0 + dog -6.0 + dtype: float64 + """ result = super().kurt( axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs )