Collapsing data into the level of certain variables and taking averages

Let’s say I have a data frame with columns A1,A2,A3,…,An, where A1,A2,A3 are categorical variables and the rest are floats. I want to create a new data frame (or equivalent) with the following features:

  1. there is one row for each possible combination of variables A1, A2, A3
  2. The columns are A4,…,An
  3. The value in a given row-column entry is the average of that column of all the rows with that particular combination of values of A1,A2,A3.

I believe groupby([:A1, :A2, :A3]) will be used somehow but not sure how.

combine(groupby(df, [:A1, :A2, :A3]), names(df, Between(:A4, :A10)) .=> mean)
3 Likes