pandas.Series.aggregate — pandas 2.2.3 documentation (original) (raw)

Series.aggregate(func=None, axis=0, *args, **kwargs)[source]#

Aggregate using one or more operations over the specified axis.

Parameters:

funcfunction, str, list or dict

Function to use for aggregating the data. If a function, must either work when passed a Series or when passed to Series.apply.

Accepted combinations are:

axis{0 or ‘index’}

Unused. Parameter needed for compatibility with DataFrame.

*args

Positional arguments to pass to func.

**kwargs

Keyword arguments to pass to func.

Returns:

scalar, Series or DataFrame

The return can be:

Notes

The aggregation operations are always performed over an axis, either the index (default) or the column axis. This behavior is different fromnumpy aggregation functions (mean, median, prod, sum, std,var), where the default is to compute the aggregation of the flattened array, e.g., numpy.mean(arr_2d) as opposed tonumpy.mean(arr_2d, axis=0).

agg is an alias for aggregate. Use the alias.

Functions that mutate the passed object can produce unexpected behavior or errors and are not supported. See Mutating with User Defined Function (UDF) methodsfor more details.

A passed user-defined-function will be passed a Series for evaluation.

Examples

s = pd.Series([1, 2, 3, 4]) s 0 1 1 2 2 3 3 4 dtype: int64

s.agg(['min', 'max']) min 1 max 4 dtype: int64