DataFrame.aggregate(self, func, axis=0, *args, **kwargs) [source]
Aggregate using one or more operations over the specified axis.
New in version 0.20.0.
| Parameters: |
|
|---|---|
| Returns: |
|
See also
DataFrame.apply
DataFrame.transform
core.groupby.GroupBy core.resample.Resampler core.window.Rolling core.window.Expanding core.window.EWM agg is an alias for aggregate. Use the alias.
A passed user-defined-function will be passed a Series for evaluation.
>>> df = pd.DataFrame([[1, 2, 3], ... [4, 5, 6], ... [7, 8, 9], ... [np.nan, np.nan, np.nan]], ... columns=['A', 'B', 'C'])
Aggregate these functions over the rows.
>>> df.agg(['sum', 'min'])
A B C
sum 12.0 15.0 18.0
min 1.0 2.0 3.0
Different aggregations per column.
>>> df.agg({'A' : ['sum', 'min'], 'B' : ['min', 'max']})
A B
max NaN 8.0
min 1.0 2.0
sum 12.0 NaN
Aggregate over the columns.
>>> df.agg("mean", axis="columns")
0 2.0
1 5.0
2 8.0
3 NaN
dtype: float64
© 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.25.0/reference/api/pandas.DataFrame.aggregate.html