How can I use different functions for different columns with groupby in pandas?
You can use a dictionary as the argument for the agg method, where the keys are the column names and the values are the functions or lists of functions. For example, df.groupby([‘col1’, ‘col2’]).agg({‘col3’: ‘mean’, ‘col4’: ‘sum’}).