Skip to content

Commit ee9a736

Browse files
authored
DOC: point out that explicitly passing axis=None is deprecated for sum, prod, var, std, sem (#55240)
point out that explicitly passing axis=None is deprecated for sum, prod, var, std, sem
1 parent 2d16863 commit ee9a736

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

pandas/core/generic.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12532,13 +12532,53 @@ def last_valid_index(self) -> Hashable | None:
1253212532
{examples}
1253312533
"""
1253412534

12535+
_sum_prod_doc = """
12536+
{desc}
12537+
12538+
Parameters
12539+
----------
12540+
axis : {axis_descr}
12541+
Axis for the function to be applied on.
12542+
For `Series` this parameter is unused and defaults to 0.
12543+
12544+
.. warning::
12545+
12546+
The behavior of DataFrame.{name} with ``axis=None`` is deprecated,
12547+
in a future version this will reduce over both axes and return a scalar
12548+
To retain the old behavior, pass axis=0 (or do not pass axis).
12549+
12550+
.. versionadded:: 2.0.0
12551+
12552+
skipna : bool, default True
12553+
Exclude NA/null values when computing the result.
12554+
numeric_only : bool, default False
12555+
Include only float, int, boolean columns. Not implemented for Series.
12556+
12557+
{min_count}\
12558+
**kwargs
12559+
Additional keyword arguments to be passed to the function.
12560+
12561+
Returns
12562+
-------
12563+
{name1} or scalar\
12564+
{see_also}\
12565+
{examples}
12566+
"""
12567+
1253512568
_num_ddof_doc = """
1253612569
{desc}
1253712570
1253812571
Parameters
1253912572
----------
1254012573
axis : {axis_descr}
1254112574
For `Series` this parameter is unused and defaults to 0.
12575+
12576+
.. warning::
12577+
12578+
The behavior of DataFrame.{name} with ``axis=None`` is deprecated,
12579+
in a future version this will reduce over both axes and return a scalar
12580+
To retain the old behavior, pass axis=0 (or do not pass axis).
12581+
1254212582
skipna : bool, default True
1254312583
Exclude NA/null values. If an entire row/column is NA, the result
1254412584
will be NA.
@@ -13246,7 +13286,7 @@ def make_doc(name: str, ndim: int) -> str:
1324613286
kwargs = {"min_count": ""}
1324713287

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

1325813298
elif name == "prod":
13259-
base_doc = _num_doc
13299+
base_doc = _sum_prod_doc
1326013300
desc = "Return the product of the values over the requested axis."
1326113301
see_also = _stat_func_see_also
1326213302
examples = _prod_examples
@@ -13540,6 +13580,7 @@ def make_doc(name: str, ndim: int) -> str:
1354013580

1354113581
docstr = base_doc.format(
1354213582
desc=desc,
13583+
name=name,
1354313584
name1=name1,
1354413585
name2=name2,
1354513586
axis_descr=axis_descr,

0 commit comments

Comments
 (0)