Skip to content

Commit

Permalink
Add PrettyTables rendering (#45)
Browse files Browse the repository at this point in the history
This PR adds PrettyTables rendering and resolves issue #36

## Example
```julia
julia> dt = DTable((a=[0,1,2,3,4,5,6,7,8,9], b=[0,1,2,3,4,5,6,7,8,9]), 10);

julia> dt
DTable with 1 partitions
Tabletype: NamedTuple
┌───────┬───────┐
│     a │     b │
│ Int64 │ Int64 │
├───────┼───────┤
│     0 │     0 │
│     1 │     1 │
│     2 │     2 │
│     3 │     3 │
│     4 │     4 │
│     5 │     5 │
│     6 │     6 │
│     7 │     7 │
│     8 │     8 │
│     9 │     9 │
└───────┴───────┘


julia> print(dt)
DTable with 1 partitions
Tabletype: NamedTuple
┌───────┬───────┐
│     a │     b │
│ Int64 │ Int64 │
├───────┼───────┤
│     0 │     0 │
│     1 │     1 │
│     2 │     2 │
│     3 │     3 │
│     4 │     4 │
│     5 │     5 │
│     6 │     6 │
│     7 │     7 │
│     8 │     8 │
│     9 │     9 │
└───────┴───────┘

```

---------

Co-authored-by: Julian Samaroo <[email protected]>
  • Loading branch information
harsharora21 and jpsamaroo authored Aug 18, 2023
1 parent 6455481 commit 4fa5d5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Dagger = "d58978e5-989f-55fb-8d15-ea34adc7bf54"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
InvertedIndices = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
TableOperations = "ab02a1b2-a7df-11e8-156e-fb1833f50b87"
Expand Down
1 change: 1 addition & 0 deletions src/DTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import DataAPI: leftjoin, ncol, nrow, innerjoin
import Tables:
columnaccess, columnnames, columns, getcolumn, istable, partitions, rowaccess, rows, schema
import DataFrames: broadcast_pair, combine, groupby, select, index, transform
import PrettyTables: pretty_table

############################################################################################
# Export
Expand Down
3 changes: 2 additions & 1 deletion src/table/dtable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ show(io::IO, d::DTable) = show(io, MIME"text/plain"(), d)
function show(io::IO, ::MIME"text/plain", d::DTable)
tabletype = d.tabletype === nothing ? "unknown (use `tabletype!(::DTable)`)" : d.tabletype
println(io, "DTable with $(nchunks(d)) partitions")
print(io, "Tabletype: $tabletype")
println(io, "Tabletype: $tabletype")
pretty_table(io, d)
return nothing
end

Expand Down

0 comments on commit 4fa5d5b

Please sign in to comment.