diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 762a183dd6914..11e8769615470 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -494,7 +494,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. @@ -504,6 +504,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 ``**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 @@ -534,7 +538,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 ------- @@ -544,10 +550,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 -----