Skip to content

Tables.jl wrapdims doesn't work on StructArray #167

@jariji

Description

@jariji

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions