From 92453264583c8df48d0ac4f89251ce3eaff233cf Mon Sep 17 00:00:00 2001 From: David Date: Sat, 17 Sep 2022 13:15:20 -0700 Subject: [PATCH 1/4] Revised the doc-string for _app_template to bring in line with current aggregate() code, in particular with regard to Named Aggregation. Also fixed text in "See Also" section, where the entries for groupby.transform and aggregate had their text swapped. --- pandas/core/groupby/groupby.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 6d9ef3c484971..47c9958006617 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -519,7 +519,7 @@ class providing the base-class of operations. Parameters ---------- -func : function, str, list or dict +func : function, str, list, dict or None Function to use for aggregating the data. If a function, must either work when passed a {klass} or when passed to {klass}.apply. @@ -529,6 +529,9 @@ class providing the base-class of operations. - string function name - list of functions and/or function names, e.g. ``[np.sum, 'mean']`` - dict of axis labels -> functions, function names or list of such. + - None, in which case output is determined from ``**kwargs`` using Named Aggregation. In this scenario the output + has one column for each element in ``**kwargs``. The name of the column is the keyword's string literal value. The + keyword's value determines the aggregation used to compute the values in the column. Can also accept a Numba JIT function with ``engine='numba'`` specified. Only passing a single function is supported @@ -559,7 +562,9 @@ class providing the base-class of operations. .. versionadded:: 1.1.0 **kwargs - Keyword arguments to be passed into func. + * If ``func`` is None, ``**kwargs`` are used to define the output names and aggregations via Named Aggregation. See + ``func`` entry. + * Otherwise, keyword arguments to be passed into func. Returns ------- @@ -569,10 +574,10 @@ class providing the base-class of operations. -------- {klass}.groupby.apply : Apply function func group-wise and combine the results together. -{klass}.groupby.transform : Aggregate using one or more - operations over the specified axis. -{klass}.aggregate : Transforms the Series on each group +{klass}.groupby.transform : Transforms the Series on each group based on the given function. +{klass}.aggregate : Aggregate using one or more + operations over the specified axis. Notes ----- From 409ee910e57e9ca0b3d79a65348749081c433a93 Mon Sep 17 00:00:00 2001 From: David Rudel Date: Wed, 21 Sep 2022 21:15:47 -0700 Subject: [PATCH 2/4] Update pandas/core/groupby/groupby.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/groupby/groupby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 47c9958006617..7a5b114d18335 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -530,7 +530,7 @@ class providing the base-class of operations. - list of functions and/or function names, e.g. ``[np.sum, 'mean']`` - dict of axis labels -> functions, function names or list of such. - None, in which case output is determined from ``**kwargs`` using Named Aggregation. In this scenario the output - has one column for each element in ``**kwargs``. The name of the column is the keyword's string literal value. The + has one column for each element in ``**kwargs``. The name of the column is a string of the keyword's variable name. The keyword's value determines the aggregation used to compute the values in the column. Can also accept a Numba JIT function with From a9a22191fbd81c98d4d1dd27eff33647643ed903 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Wed, 7 Dec 2022 17:04:59 +0000 Subject: [PATCH 3/4] fixup --- pandas/core/groupby/groupby.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 5e892d5c018b0..68d6368718a01 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -538,9 +538,11 @@ class providing the base-class of operations. - string function name - list of functions and/or function names, e.g. ``[np.sum, 'mean']`` - dict of axis labels -> functions, function names or list of such. - - None, in which case output is determined from ``**kwargs`` using Named Aggregation. In this scenario the output - has one column for each element in ``**kwargs``. The name of the column is a string of the keyword's variable name. The - keyword's value determines the aggregation used to compute the values in the column. + - None, in which case output is determined from ``**kwargs`` using Named + Aggregation. In this scenario the output has one column for each element in + ``**kwargs``. The name of the column is a string of the keyword's variable name. + The keyword's value determines the aggregation used to compute the values in + the column. Can also accept a Numba JIT function with ``engine='numba'`` specified. Only passing a single function is supported @@ -571,8 +573,8 @@ class providing the base-class of operations. .. versionadded:: 1.1.0 **kwargs - * If ``func`` is None, ``**kwargs`` are used to define the output names and aggregations via Named Aggregation. See - ``func`` entry. + * If ``func`` is None, ``**kwargs`` are used to define the output names and + aggregations via Named Aggregation. See ``func`` entry. * Otherwise, keyword arguments to be passed into func. Returns From e4902496b8c7404ba2a50d67ca0d219f8ef2b49c Mon Sep 17 00:00:00 2001 From: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com> Date: Wed, 14 Dec 2022 21:46:51 -0500 Subject: [PATCH 4/4] Language tweaks --- pandas/core/groupby/groupby.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 68d6368718a01..59efee7f2d1a3 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -538,11 +538,10 @@ class providing the base-class of operations. - string function name - list of functions and/or function names, e.g. ``[np.sum, 'mean']`` - dict of axis labels -> functions, function names or list of such. - - None, in which case output is determined from ``**kwargs`` using Named - Aggregation. In this scenario the output has one column for each element in - ``**kwargs``. The name of the column is a string of the keyword's variable name. - The keyword's value determines the aggregation used to compute the values in - the column. + - None, in which case ``**kwargs`` are used with Named Aggregation. Here the + output has one column for each element in ``**kwargs``. The name of the + column is keyword, whereas the value determines the aggregation used to compute + the values in the column. Can also accept a Numba JIT function with ``engine='numba'`` specified. Only passing a single function is supported