Skip to content

Commit 1e02cdd

Browse files
tuhinsharma121pmhatre1
authored andcommitted
DOC: Enforce Numpy Docstring Validation for pandas.DataFrame.prod (pandas-dev#58512)
* DOC: add RT03 in pandas.DataFrame.prod * DOC: remove RT03 in pandas.DataFrame.prod * DOC: remove RT03 in pandas.DataFrame.product * DOC: add RT03 in pandas.DataFrame.prod
1 parent 8718643 commit 1e02cdd

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

ci/code_checks.sh

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7575
-i "pandas.DataFrame.median RT03,SA01" \
7676
-i "pandas.DataFrame.min RT03" \
7777
-i "pandas.DataFrame.plot PR02,SA01" \
78-
-i "pandas.DataFrame.prod RT03" \
79-
-i "pandas.DataFrame.product RT03" \
8078
-i "pandas.DataFrame.sem PR01,RT03,SA01" \
8179
-i "pandas.DataFrame.skew RT03,SA01" \
8280
-i "pandas.DataFrame.sparse PR01" \

pandas/core/frame.py

+67-1
Original file line numberDiff line numberDiff line change
@@ -11730,7 +11730,6 @@ def sum(
1173011730
return result
1173111731

1173211732
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="prod")
11733-
@doc(make_doc("prod", ndim=2))
1173411733
def prod(
1173511734
self,
1173611735
axis: Axis | None = 0,
@@ -11739,6 +11738,73 @@ def prod(
1173911738
min_count: int = 0,
1174011739
**kwargs,
1174111740
) -> Series:
11741+
"""
11742+
Return the product of the values over the requested axis.
11743+
11744+
Parameters
11745+
----------
11746+
axis : {index (0), columns (1)}
11747+
Axis for the function to be applied on.
11748+
For `Series` this parameter is unused and defaults to 0.
11749+
11750+
.. warning::
11751+
11752+
The behavior of DataFrame.prod with ``axis=None`` is deprecated,
11753+
in a future version this will reduce over both axes and return a scalar
11754+
To retain the old behavior, pass axis=0 (or do not pass axis).
11755+
11756+
.. versionadded:: 2.0.0
11757+
11758+
skipna : bool, default True
11759+
Exclude NA/null values when computing the result.
11760+
numeric_only : bool, default False
11761+
Include only float, int, boolean columns. Not implemented for Series.
11762+
11763+
min_count : int, default 0
11764+
The required number of valid values to perform the operation. If fewer than
11765+
``min_count`` non-NA values are present the result will be NA.
11766+
**kwargs
11767+
Additional keyword arguments to be passed to the function.
11768+
11769+
Returns
11770+
-------
11771+
Series or scalar
11772+
The product of the values over the requested axis.
11773+
11774+
See Also
11775+
--------
11776+
Series.sum : Return the sum.
11777+
Series.min : Return the minimum.
11778+
Series.max : Return the maximum.
11779+
Series.idxmin : Return the index of the minimum.
11780+
Series.idxmax : Return the index of the maximum.
11781+
DataFrame.sum : Return the sum over the requested axis.
11782+
DataFrame.min : Return the minimum over the requested axis.
11783+
DataFrame.max : Return the maximum over the requested axis.
11784+
DataFrame.idxmin : Return the index of the minimum over the requested axis.
11785+
DataFrame.idxmax : Return the index of the maximum over the requested axis.
11786+
11787+
Examples
11788+
--------
11789+
By default, the product of an empty or all-NA Series is ``1``
11790+
11791+
>>> pd.Series([], dtype="float64").prod()
11792+
1.0
11793+
11794+
This can be controlled with the ``min_count`` parameter
11795+
11796+
>>> pd.Series([], dtype="float64").prod(min_count=1)
11797+
nan
11798+
11799+
Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
11800+
empty series identically.
11801+
11802+
>>> pd.Series([np.nan]).prod()
11803+
1.0
11804+
11805+
>>> pd.Series([np.nan]).prod(min_count=1)
11806+
nan
11807+
"""
1174211808
result = super().prod(
1174311809
axis=axis,
1174411810
skipna=skipna,

0 commit comments

Comments
 (0)