It works on DataFrame but not StructArray.
using AxisKeys, DataFrames, StructArrays
julia> wrapdims(DataFrame(a=[1,1,2,2], b=[:x, :y, :x, :y], c=[10, 20, 30, 40]), :c, :a, :b)
2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓ a ∈ 2-element Vector{Int64}
→ b ∈ 2-element Vector{Symbol}
And data, 2×2 Matrix{Int64}:
(:x) (:y)
(1) 10 20
(2) 30 40
julia> wrapdims(StructArray(a=[1,1,2,2], b=[:x, :y, :x, :y], c=[10, 20, 30, 40]), :c, :a, :b)
ERROR: ArgumentError: wrong number of names, got (:c, :a, :b) with ndims(A) == 1
Stacktrace:
[1] check_names(A::StructVector{@NamedTuple{…}, @NamedTuple{…}, Int64}, names::Tuple{Symbol, Symbol, Symbol})
@ AxisKeys ~/.julia/packages/AxisKeys/sYP4R/src/wrap.jl:103
[2] wrapdims(::StructVector{@NamedTuple{…}, @NamedTuple{…}, Int64}, ::Symbol, ::Symbol, ::Symbol)
@ AxisKeys ~/.julia/packages/AxisKeys/sYP4R/src/wrap.jl:85
[3] top-level scope
It works on
DataFramebut notStructArray.