Skip to content

DOC: Enforce Numpy Docstring Validation for pandas.DataFrame.skew #58514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.prod RT03" \
-i "pandas.DataFrame.product RT03" \
-i "pandas.DataFrame.sem PR01,RT03,SA01" \
-i "pandas.DataFrame.skew RT03,SA01" \
-i "pandas.DataFrame.sparse PR01" \
-i "pandas.DataFrame.std PR01,RT03,SA01" \
-i "pandas.DataFrame.sum RT03" \
Expand Down
75 changes: 74 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -12029,14 +12029,87 @@ def skew(
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="skew")
@doc(make_doc("skew", ndim=2))
def skew(
self,
axis: Axis | None = 0,
skipna: bool = True,
numeric_only: bool = False,
**kwargs,
) -> Series | Any:
"""
Return unbiased skew over requested axis.

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 skew over requested axis.

See Also
--------
Dataframe.kurt : Returns unbiased kurtosis over requested axis.

Examples
--------
>>> s = pd.Series([1, 2, 3])
>>> s.skew()
0.0

With a DataFrame

>>> df = pd.DataFrame(
... {"a": [1, 2, 3], "b": [2, 3, 4], "c": [1, 3, 5]},
... index=["tiger", "zebra", "cow"],
... )
>>> df
a b c
tiger 1 2 1
zebra 2 3 3
cow 3 4 5
>>> df.skew()
a 0.0
b 0.0
c 0.0
dtype: float64

Using axis=1

>>> df.skew(axis=1)
tiger 1.732051
zebra -1.732051
cow 0.000000
dtype: float64

In this case, `numeric_only` should be set to `True` to avoid
getting an error.

>>> df = pd.DataFrame(
... {"a": [1, 2, 3], "b": ["T", "Z", "X"]}, index=["tiger", "zebra", "cow"]
... )
>>> df.skew(numeric_only=True)
a 0.0
dtype: float64
"""
result = super().skew(
axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
)
Expand Down