Skip to content

DOC: point out that explicitly passing axis=None is deprecated for sum, prod, var, std, sem #55240

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
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
45 changes: 43 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12532,13 +12532,53 @@ def last_valid_index(self) -> Hashable | None:
{examples}
"""

_sum_prod_doc = """
{desc}

Parameters
----------
axis : {axis_descr}
Axis for the function to be applied on.
For `Series` this parameter is unused and defaults to 0.

.. warning::

The behavior of DataFrame.{name} with ``axis=None`` is deprecated,
in a future version this will reduce over both axes and return a scalar
To retain the old behavior, pass axis=0 (or do not pass axis).

.. 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. Not implemented for Series.

{min_count}\
**kwargs
Additional keyword arguments to be passed to the function.

Returns
-------
{name1} or scalar\
{see_also}\
{examples}
"""

_num_ddof_doc = """
{desc}

Parameters
----------
axis : {axis_descr}
For `Series` this parameter is unused and defaults to 0.

.. warning::

The behavior of DataFrame.{name} with ``axis=None`` is deprecated,
in a future version this will reduce over both axes and return a scalar
To retain the old behavior, pass axis=0 (or do not pass axis).

skipna : bool, default True
Exclude NA/null values. If an entire row/column is NA, the result
will be NA.
Expand Down Expand Up @@ -13246,7 +13286,7 @@ def make_doc(name: str, ndim: int) -> str:
kwargs = {"min_count": ""}

elif name == "sum":
base_doc = _num_doc
base_doc = _sum_prod_doc
desc = (
"Return the sum of the values over the requested axis.\n\n"
"This is equivalent to the method ``numpy.sum``."
Expand All @@ -13256,7 +13296,7 @@ def make_doc(name: str, ndim: int) -> str:
kwargs = {"min_count": _min_count_stub}

elif name == "prod":
base_doc = _num_doc
base_doc = _sum_prod_doc
desc = "Return the product of the values over the requested axis."
see_also = _stat_func_see_also
examples = _prod_examples
Expand Down Expand Up @@ -13540,6 +13580,7 @@ def make_doc(name: str, ndim: int) -> str:

docstr = base_doc.format(
desc=desc,
name=name,
name1=name1,
name2=name2,
axis_descr=axis_descr,
Expand Down