Skip to content

Commit 8cc036c

Browse files
DOC: Enforce Numpy Docstring Validation for pandas.DataFrame.skew (#58514)
DOC: remove RT03,SA01 in pandas.DataFrame.skew
1 parent 439526c commit 8cc036c

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7676
-i "pandas.DataFrame.min RT03" \
7777
-i "pandas.DataFrame.plot PR02,SA01" \
7878
-i "pandas.DataFrame.sem PR01,RT03,SA01" \
79-
-i "pandas.DataFrame.skew RT03,SA01" \
8079
-i "pandas.DataFrame.sparse PR01" \
8180
-i "pandas.DataFrame.std PR01,RT03,SA01" \
8281
-i "pandas.DataFrame.sum RT03" \

pandas/core/frame.py

+74-1
Original file line numberDiff line numberDiff line change
@@ -12095,14 +12095,87 @@ def skew(
1209512095
) -> Series | Any: ...
1209612096

1209712097
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="skew")
12098-
@doc(make_doc("skew", ndim=2))
1209912098
def skew(
1210012099
self,
1210112100
axis: Axis | None = 0,
1210212101
skipna: bool = True,
1210312102
numeric_only: bool = False,
1210412103
**kwargs,
1210512104
) -> Series | Any:
12105+
"""
12106+
Return unbiased skew over requested axis.
12107+
12108+
Normalized by N-1.
12109+
12110+
Parameters
12111+
----------
12112+
axis : {index (0), columns (1)}
12113+
Axis for the function to be applied on.
12114+
For `Series` this parameter is unused and defaults to 0.
12115+
12116+
For DataFrames, specifying ``axis=None`` will apply the aggregation
12117+
across both axes.
12118+
12119+
.. versionadded:: 2.0.0
12120+
12121+
skipna : bool, default True
12122+
Exclude NA/null values when computing the result.
12123+
numeric_only : bool, default False
12124+
Include only float, int, boolean columns.
12125+
12126+
**kwargs
12127+
Additional keyword arguments to be passed to the function.
12128+
12129+
Returns
12130+
-------
12131+
Series or scalar
12132+
Unbiased skew over requested axis.
12133+
12134+
See Also
12135+
--------
12136+
Dataframe.kurt : Returns unbiased kurtosis over requested axis.
12137+
12138+
Examples
12139+
--------
12140+
>>> s = pd.Series([1, 2, 3])
12141+
>>> s.skew()
12142+
0.0
12143+
12144+
With a DataFrame
12145+
12146+
>>> df = pd.DataFrame(
12147+
... {"a": [1, 2, 3], "b": [2, 3, 4], "c": [1, 3, 5]},
12148+
... index=["tiger", "zebra", "cow"],
12149+
... )
12150+
>>> df
12151+
a b c
12152+
tiger 1 2 1
12153+
zebra 2 3 3
12154+
cow 3 4 5
12155+
>>> df.skew()
12156+
a 0.0
12157+
b 0.0
12158+
c 0.0
12159+
dtype: float64
12160+
12161+
Using axis=1
12162+
12163+
>>> df.skew(axis=1)
12164+
tiger 1.732051
12165+
zebra -1.732051
12166+
cow 0.000000
12167+
dtype: float64
12168+
12169+
In this case, `numeric_only` should be set to `True` to avoid
12170+
getting an error.
12171+
12172+
>>> df = pd.DataFrame(
12173+
... {"a": [1, 2, 3], "b": ["T", "Z", "X"]}, index=["tiger", "zebra", "cow"]
12174+
... )
12175+
>>> df.skew(numeric_only=True)
12176+
a 0.0
12177+
dtype: float64
12178+
"""
1210612179
result = super().skew(
1210712180
axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
1210812181
)

0 commit comments

Comments
 (0)