OK, with foldl this actually works for any number of groups:
julia> t = table((group = [1,1,2,2,3,3], x = [1,2,3,4,5,6]))
Table with 6 rows, 2 columns:
group x
────────
1 1
1 2
2 3
2 4
3 5
3 6
julia> t2 = groupby(t, :group, usekey = true) do k, r
(x2 = r.x .+ k.group, y2 = rand(length(r)))
end
Table with 3 rows, 3 columns:
group x2 y2
────────────────────────────────────
1 [2, 3] [0.0581229, 0.019784]
2 [5, 6] [0.63852, 0.855233]
3 [8, 9] [0.023636, 0.783005]
julia> foldl(merge, table.(rows(select(t2, Not(:group)))))
Table with 6 rows, 2 columns:
x2 y2
─────────────
2 0.0581229
3 0.019784
5 0.63852
6 0.855233
8 0.023636
9 0.783005