Functionally, sum() and agg('sum') do the same thing when used after a GroupBy. However, agg() is more flexible and allows you to perform multiple aggregate operations at once. For example, Using GroupBy to count occurrences by Product and Region: grouped_data = df.groupby(['Product', 'Region']).size() Or Using crosstab to count occurrences by Product and Region: crosstab_data = pd.crosstab(index=df['Product'], columns=df['Region'])