using DataManipulation, StructArrays, PrettyTables
julia> let d = StructArray(a=[1,1,2,2], b=[:x, :y, :x, :y], c=[10, 20, 30, 40])
pretty_table(d)
@p begin
d
group_vg((;_.a,))
map((;key(_)..., (_.b .=> _.c)...))
pretty_table
end
end
┌───────┬────────┬───────┐
│ a │ b │ c │
│ Int64 │ Symbol │ Int64 │
├───────┼────────┼───────┤
│ 1 │ x │ 10 │
│ 1 │ y │ 20 │
│ 2 │ x │ 30 │
│ 2 │ y │ 40 │
└───────┴────────┴───────┘
┌───────┬───────┬───────┐
│ a │ x │ y │
│ Int64 │ Int64 │ Int64 │
├───────┼───────┼───────┤
│ 1 │ 10 │ 20 │
│ 2 │ 30 │ 40 │
└───────┴───────┴───────┘
Is there a nicer approach to table unstack
?
Elements a little less elegant than I’d like:
- the key
...
splat - the
.=>
broadcast - the pairs
...
splat
cc @aplavin