-
Notifications
You must be signed in to change notification settings - Fork 3
Add PrettyTables rendering for GDTable #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Julian Samaroo <[email protected]>
Codecov ReportPatch coverage has no change and project coverage change:
❗ 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. Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
==========================================
- Coverage 95.47% 92.46% -3.01%
==========================================
Files 12 12
Lines 861 889 +28
==========================================
Hits 822 822
- Misses 39 67 +28
☔ View full report in Codecov by Sentry. |
Newer commit makes it more like dataframe. ExampleCreate 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); Groupby without functionjulia> 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 │
└───┴───┘
Groupby with functionjulia> 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