Skip to content

Commit 816b4af

Browse files
committed
Update Groupby.prod
1 parent 224c6ff commit 816b4af

File tree

1 file changed

+30
-37
lines changed

1 file changed

+30
-37
lines changed

pandas/core/groupby/groupby.py

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -164,32 +164,6 @@ class providing the base-class of operations.
164164
to each row or column of a DataFrame.
165165
"""
166166

167-
_groupby_agg_method_template = """
168-
Compute {fname} of group values.
169-
170-
Parameters
171-
----------
172-
numeric_only : bool, default {no}
173-
Include only float, int, boolean columns.
174-
175-
.. versionchanged:: 2.0.0
176-
177-
numeric_only no longer accepts ``None``.
178-
179-
min_count : int, default {mc}
180-
The required number of valid values to perform the operation. If fewer
181-
than ``min_count`` non-NA values are present the result will be NA.
182-
183-
Returns
184-
-------
185-
Series or DataFrame
186-
Computed {fname} of values within each group.
187-
188-
Examples
189-
--------
190-
{example}
191-
"""
192-
193167
_groupby_agg_method_engine_template = """
194168
Compute {fname} of group values.
195169
@@ -3029,13 +3003,30 @@ def sum(
30293003
return result
30303004

30313005
@final
3032-
@doc(
3033-
_groupby_agg_method_template,
3034-
fname="prod",
3035-
no=False,
3036-
mc=0,
3037-
example=dedent(
3038-
"""\
3006+
def prod(self, numeric_only: bool = False, min_count: int = 0) -> NDFrameT:
3007+
"""
3008+
Compute prod of group values.
3009+
3010+
Parameters
3011+
----------
3012+
numeric_only : bool, default False
3013+
Include only float, int, boolean columns.
3014+
3015+
.. versionchanged:: 2.0.0
3016+
3017+
numeric_only no longer accepts ``None``.
3018+
3019+
min_count : int, default 0
3020+
The required number of valid values to perform the operation. If fewer
3021+
than ``min_count`` non-NA values are present the result will be NA.
3022+
3023+
Returns
3024+
-------
3025+
Series or DataFrame
3026+
Computed prod of values within each group.
3027+
3028+
Examples
3029+
--------
30393030
For SeriesGroupBy:
30403031
30413032
>>> lst = ['a', 'a', 'b', 'b']
@@ -3066,10 +3057,12 @@ def sum(
30663057
b c
30673058
a
30683059
1 16 10
3069-
2 30 72"""
3070-
),
3071-
)
3072-
def prod(self, numeric_only: bool = False, min_count: int = 0) -> NDFrameT:
3060+
2 30 72
3061+
3062+
See Also
3063+
--------
3064+
DataFrame.prod : Return the product of the values over the requested axis.
3065+
"""
30733066
return self._agg_general(
30743067
numeric_only=numeric_only, min_count=min_count, alias="prod", npfunc=np.prod
30753068
)

0 commit comments

Comments
 (0)