-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Hi!
Recently, a user of my package PrettyTables.jl found an issue (ronisbr/PrettyTables.jl#51) when trying to print a DataFrame from Pandas. It turns out that, although Pandas.DataFrame provide full support for Tables.jl API (both row and column access), the methods Tables.rowaccess and Tables.columnaccess return false. Hence, PrettyTables.jl does not know how to get the data.
My suggestion is to define the following two methods:
Tables.columnaccess(::Pandas.DataFrame) = true
Tables.rowaccess(::Pandas.DataFrame) = truewhich will tell to the packages that Pandas.DataFrame has the capability to access data by rows and columns. In this case, we can do:
julia> using PrettyTables
julia> using Tables
julia> using Pandas
julia> df = DataFrame(Dict(:age=>[27, 29, 27], :name=>["James", "Jill", "Jake"]));
julia> Tables.columnaccess(::Pandas.DataFrame) = true
julia> pretty_table(df)
┌─────┬───────┐
│ age │ name │
├─────┼───────┤
│ 27 │ James │
│ 29 │ Jill │
│ 27 │ Jake │
└─────┴───────┘Metadata
Metadata
Assignees
Labels
No labels