I\'ve frequented used pandas\' agg() function to run summary statistics on every column of a data.frame. For example, here\'s how you would produce the mean an
In order to preserve order, you'll need to pass .groupby(..., sort=False). In your case the grouping column is already sorted, so it does not make difference, but generally one must use the sort=False flag: