@@ -164,32 +164,6 @@ class providing the base-class of operations.
164
164
to each row or column of a DataFrame.
165
165
"""
166
166
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
-
193
167
_groupby_agg_method_engine_template = """
194
168
Compute {fname} of group values.
195
169
@@ -3029,16 +3003,38 @@ def sum(
3029
3003
return result
3030
3004
3031
3005
@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
+ See Also
3029
+ --------
3030
+ Series.prod : Return the product of the values over the requested axis.
3031
+ DataFrame.prod : Return the product of the values over the requested axis.
3032
+
3033
+ Examples
3034
+ --------
3039
3035
For SeriesGroupBy:
3040
3036
3041
- >>> lst = ['a', 'a', 'b', 'b' ]
3037
+ >>> lst = ["a", "a", "b", "b" ]
3042
3038
>>> ser = pd.Series([1, 2, 3, 4], index=lst)
3043
3039
>>> ser
3044
3040
a 1
@@ -3054,8 +3050,11 @@ def sum(
3054
3050
For DataFrameGroupBy:
3055
3051
3056
3052
>>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
3057
- >>> df = pd.DataFrame(data, columns=["a", "b", "c"],
3058
- ... index=["tiger", "leopard", "cheetah", "lion"])
3053
+ >>> df = pd.DataFrame(
3054
+ ... data,
3055
+ ... columns=["a", "b", "c"],
3056
+ ... index=["tiger", "leopard", "cheetah", "lion"],
3057
+ ... )
3059
3058
>>> df
3060
3059
a b c
3061
3060
tiger 1 8 2
@@ -3066,10 +3065,8 @@ def sum(
3066
3065
b c
3067
3066
a
3068
3067
1 16 10
3069
- 2 30 72"""
3070
- ),
3071
- )
3072
- def prod (self , numeric_only : bool = False , min_count : int = 0 ) -> NDFrameT :
3068
+ 2 30 72
3069
+ """
3073
3070
return self ._agg_general (
3074
3071
numeric_only = numeric_only , min_count = min_count , alias = "prod" , npfunc = np .prod
3075
3072
)
0 commit comments