Source Code:
(back to article)
import pandas as pd df = pd.DataFrame({'A': ['foo', 'bar', 'baz', 'foo', 'bar', 'baz'], 'B': [1, 2, 3, 4, 5, 6]}) grouped = df.groupby('A') result = grouped.agg({'B': ['count', 'mean', 'sum']}) print(result)
Result:
Report an issue