maxframe.dataframe.Series.aggregate#
- Series.aggregate(func=None, axis=0, **kw)#
Aggregate using one or more operations over the specified axis.
- Parameters:
- Returns:
The return can be:
scalar : when Series.agg is called with single function
Series : when DataFrame.agg is called with a single function
DataFrame : when DataFrame.agg is called with several functions
- Return type:
Examples
>>> import maxframe.dataframe as md >>> df = md.DataFrame([[1, 2, 3], ... [4, 5, 6], ... [7, 8, 9], ... [np.nan, np.nan, np.nan]], ... columns=['A', 'B', 'C']).execute()
Aggregate these functions over the rows.
>>> df.agg(['sum', 'min']).execute() A B C min 1.0 2.0 3.0 sum 12.0 15.0 18.0
Different aggregations per column.
>>> df.agg({'A' : ['sum', 'min'], 'B' : ['min', 'max']}).execute() A B max NaN 8.0 min 1.0 2.0 sum 12.0 NaN
Aggregate different functions over the columns and rename the index of the resulting DataFrame.
>>> df.agg(x=('A', 'max'), y=('B', 'min'), z=('C', 'mean')).execute() A B C x 7.0 NaN NaN y NaN 2.0 NaN z NaN NaN 6.0
>>> s = md.Series([1, 2, 3, 4]) >>> s.agg('min').execute() 1
>>> s.agg(['min', 'max']).execute() max 4 min 1