Skip to content

Commit

Permalink
DOC: Enforce Numpy Docstring Validation for pandas.DataFrame.prod (#5…
Browse files Browse the repository at this point in the history
…8512)

* 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
  • Loading branch information
tuhinsharma121 committed May 1, 2024
1 parent 7257a89 commit 439526c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
2 changes: 0 additions & 2 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.median RT03,SA01" \
-i "pandas.DataFrame.min RT03" \
-i "pandas.DataFrame.plot PR02,SA01" \
-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" \
Expand Down
68 changes: 67 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -11730,7 +11730,6 @@ def sum(
return result

@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="prod")
@doc(make_doc("prod", ndim=2))
def prod(
self,
axis: Axis | None = 0,
Expand All @@ -11739,6 +11738,73 @@ def prod(
min_count: int = 0,
**kwargs,
) -> Series:
"""
Return the product of the values over the requested axis.
Parameters
----------
axis : {index (0), columns (1)}
Axis for the function to be applied on.
For `Series` this parameter is unused and defaults to 0.
.. warning::
The behavior of DataFrame.prod 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 : int, default 0
The required number of valid values to perform the operation. If fewer than
``min_count`` non-NA values are present the result will be NA.
**kwargs
Additional keyword arguments to be passed to the function.
Returns
-------
Series or scalar
The product of the values over the requested axis.
See Also
--------
Series.sum : Return the sum.
Series.min : Return the minimum.
Series.max : Return the maximum.
Series.idxmin : Return the index of the minimum.
Series.idxmax : Return the index of the maximum.
DataFrame.sum : Return the sum over the requested axis.
DataFrame.min : Return the minimum over the requested axis.
DataFrame.max : Return the maximum over the requested axis.
DataFrame.idxmin : Return the index of the minimum over the requested axis.
DataFrame.idxmax : Return the index of the maximum over the requested axis.
Examples
--------
By default, the product of an empty or all-NA Series is ``1``
>>> pd.Series([], dtype="float64").prod()
1.0
This can be controlled with the ``min_count`` parameter
>>> pd.Series([], dtype="float64").prod(min_count=1)
nan
Thanks to the ``skipna`` parameter, ``min_count`` handles all-NA and
empty series identically.
>>> pd.Series([np.nan]).prod()
1.0
>>> pd.Series([np.nan]).prod(min_count=1)
nan
"""
result = super().prod(
axis=axis,
skipna=skipna,
Expand Down

0 comments on commit 439526c

Please sign in to comment.