Combining a col from each DF group into a single DF

df=DataFrame(dtype=repeat(["AA","BB","CC"], inner=4), val=collect(1:12))
flatten(unstack(df, :dtype, :val, valuestransform=identity), Cols(:))

if the ultimate goal is to apply an aggregation function to the values of the various groups, you can avoid going through groupby and / or flatten in the following way


unstack(df, :dtype, :val, valuestransform=sum)
unstack(df, :dtype, :val, valuestransform=x->sum(x)/length(x))