pandas.core.groupby.DataFrameGroupBy.agg

DataFrameGroupBy.agg(arg, *args, **kwargs) [source]

Aggregate using input function or dict of {column -> function}

Parameters:

arg : function or dict

Function to use for aggregating groups. If a function, must either work when passed a DataFrame or when passed to DataFrame.apply. If passed a dict, the keys must be DataFrame column names.

Accepted Combinations are:
  • string cythonized function name
  • function
  • list of functions
  • dict of columns -> functions
  • nested dict of names -> dicts of functions
Returns:

aggregated : DataFrame

Notes

Numpy functions mean/median/prod/sum/std/var are special cased so the default behavior is applying the function along axis=0 (e.g., np.mean(arr_2d, axis=0)) as opposed to mimicking the default Numpy behavior (e.g., np.mean(arr_2d)).

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.19.2/generated/pandas.core.groupby.DataFrameGroupBy.agg.html