Skip to content

PrettyTables for 2-dimensional KeyedArrays #243

@jariji

Description

@jariji

I am seeking a table that looks more like the REPL display of the KeyedArray, rather than stacking it into a DataFrame-style format. Is that possible?

using RectiGrids, AxisKeys, PrettyTables

julia> grid('a':'c', 'A':'C')
2-dimensional KeyedArray(...) with keys:
   3-element StepRange{Char,...}
   3-element StepRange{Char,...}
And data, 3×3 RectiGrids.RectiGridArr{Base.OneTo(2), Tuple{Char, Char}, 2, Tuple{Nothing, Nothing}, Tuple{StepRange{Char, Int64}, StepRange{Char, Int64}}}:
         ('A')         ('B')         ('C')
  ('a')    ('a', 'A')    ('a', 'B')    ('a', 'C')
  ('b')    ('b', 'A')    ('b', 'B')    ('b', 'C')
  ('c')    ('c', 'A')    ('c', 'B')    ('c', 'C')

julia> pretty_table(grid('a':'c', 'A':'C'))
┌───────┬───────┬────────────┐
│ dim_1 │ dim_2 │      value │
├───────┼───────┼────────────┤
│     a │     A │ ('a', 'A') │
│     b │     A │ ('b', 'A') │
│     c │     A │ ('c', 'A') │
│     a │     B │ ('a', 'B') │
│     b │     B │ ('b', 'B') │
│     c │     B │ ('c', 'B') │
│     a │     C │ ('a', 'C') │
│     b │     C │ ('b', 'C') │
│     c │     C │ ('c', 'C') │
└───────┴───────┴────────────┘

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