Open harsharora21 opened 1 year ago
could you try getting an effect like this? when you iterate a gdtable you should be getting dtable type elements so should be fairly easy DataFrames code could be a hint as well
Patch coverage has no change and project coverage change: -3.01%
:warning:
Comparison is base (
94d66ed
) 95.47% compared to head (cd4c64c
) 92.46%.
:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Newer commit makes it more like dataframe.
Create a sample table
julia> dt = DTable((a=[0,1,2,0,1,2,0,0,1,1], b=[0,1,2,3,4,5,6,7,8,9]), 10);
julia> gdt = groupby(dt, :a);
julia> gdt #limited printing
GDTable with 3 partitions and 3 keys
Tabletype: NamedTuple
Grouped by: [:a]
First Group (4 rows): a = 0
┌───┬───┐
│ a │ b │
├───┼───┤
│ 0 │ 0 │
│ 0 │ 3 │
│ 0 │ 6 │
│ 0 │ 7 │
└───┴───┘
⋮
Last Group (2 rows): a = 2
┌───┬───┐
│ a │ b │
├───┼───┤
│ 2 │ 2 │
│ 2 │ 5 │
└───┴───┘
julia> print(gdt)
GDTable with 3 partitions and 3 keys
Tabletype: NamedTuple
Grouped by: [:a]
Group 1 (4 rows): a = 0
┌───┬───┐
│ a │ b │
├───┼───┤
│ 0 │ 0 │
│ 0 │ 3 │
│ 0 │ 6 │
│ 0 │ 7 │
└───┴───┘
Group 2 (4 rows): a = 1
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 1 │
│ 1 │ 4 │
│ 1 │ 8 │
│ 1 │ 9 │
└───┴───┘
Group 3 (2 rows): a = 2
┌───┬───┐
│ a │ b │
├───┼───┤
│ 2 │ 2 │
│ 2 │ 5 │
└───┴───┘
julia> function rowsum(row)
return row.a + row.b
end
rowsum (generic function with 1 method)
julia> gdt = groupby(dt, rowsum);
julia> gdt #limited printing
GDTable with 9 partitions and 9 keys
Tabletype: NamedTuple
Grouped by: rowsum
First Group (1 rows): Function rowsum = 0
┌───┬───┐
│ a │ b │
├───┼───┤
│ 0 │ 0 │
└───┴───┘
⋮
Last Group (1 rows): Function rowsum = 10
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 9 │
└───┴───┘
julia> print(gdt)
GDTable with 9 partitions and 9 keys
Tabletype: NamedTuple
Grouped by: rowsum
Group 1 (1 rows): Function rowsum = 0
┌───┬───┐
│ a │ b │
├───┼───┤
│ 0 │ 0 │
└───┴───┘
Group 2 (1 rows): Function rowsum = 2
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 1 │
└───┴───┘
Group 3 (1 rows): Function rowsum = 3
┌───┬───┐
│ a │ b │
├───┼───┤
│ 0 │ 3 │
└───┴───┘
Group 4 (1 rows): Function rowsum = 4
┌───┬───┐
│ a │ b │
├───┼───┤
│ 2 │ 2 │
└───┴───┘
Group 5 (1 rows): Function rowsum = 5
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 4 │
└───┴───┘
Group 6 (1 rows): Function rowsum = 6
┌───┬───┐
│ a │ b │
├───┼───┤
│ 0 │ 6 │
└───┴───┘
Group 7 (2 rows): Function rowsum = 7
┌───┬───┐
│ a │ b │
├───┼───┤
│ 2 │ 5 │
│ 0 │ 7 │
└───┴───┘
Group 8 (1 rows): Function rowsum = 9
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 8 │
└───┴───┘
Group 9 (1 rows): Function rowsum = 10
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 9 │
└───┴───┘
As suggested by @krynju, This PR adds PrettyTables rendering for GDTable
Example