Skip to content

Request: support DataFrame directly with Table #239

@nathanrboyer

Description

@nathanrboyer

I thought that I could make a Term.Table out of a DataFrame directly since DataFrames conform to the Tables.jl interface. However, it did not work, and I have to manually redefine the header after converting.

julia> using DataFrames, Term

julia> table = DataFrame(x = 1:3, y = ["A","B","C"])
3×2 DataFrame
 Row │ x      y      
     │ Int64  String 
─────┼───────────────
   11  A
   22  B
   33  C

julia> Term.Table(
           table,
           style="red",
       )
ERROR: MethodError: no method matching Term.Tables.Table(::DataFrame; style::String)

julia> Term.Table(
           Matrix(table),
           style="red",
       )
            ╷
   Column1  │  Column2  
╺━━━━━━━━━━━┿━━━━━━━━━━━╸
      1     │     A
╶───────────┼───────────╴
      2     │     B
╶───────────┼───────────╴
      3     │     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