Split-Apply-Combine on many columns at once? Looking for equivalent to Stata's collapse

Its fairly similar. Here is the syntax for plain DataFrames.

combine(groupby(df,:id), :test_score => mean, :wins_scholarship => maximum, [:gender,:race] .=> first)

The names will be autogenerated like :test_score_mean. You can add => :newcolname to any of those to manually name it.

8 Likes