Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame([[2, 3, 4],
                   [5, 6, 7],
                   [8, 9, 10],
                   [np.nan, np.nan, np.nan]],
                  columns=['P', 'Q', 'R'])

Aggregate these functions over the rows.

In [3]:
df.agg(['sum', 'min'])
Out[3]:
P Q R
sum 15.0 18.0 21.0
min 2.0 3.0 4.0

Different aggregations per column.

In [4]:
df.agg({'P' : ['sum', 'min'], 'Q' : ['min', 'max']})
Out[4]:
P Q
max NaN 9.0
min 2.0 3.0
sum 15.0 NaN

Aggregate over the columns.

In [5]:
df.agg("mean", axis="columns")
Out[5]:
0    3.0
1    6.0
2    9.0
3    NaN
dtype: float64