From 620aa1fd8ee874697151d5ce5718ed484344942d Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Sun, 13 Aug 2023 21:27:47 +0530 Subject: [PATCH 1/8] add PrettyTables.jl to dependencies --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 8cf8eff..75f05f0 100644 --- a/Project.toml +++ b/Project.toml @@ -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" From 15e13e153ccf7b8adea16cdebb44ec640ef26c5d Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Sun, 13 Aug 2023 21:28:11 +0530 Subject: [PATCH 2/8] added pretty_table import --- src/DTables.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DTables.jl b/src/DTables.jl index 59084dc..4b8c1a7 100644 --- a/src/DTables.jl +++ b/src/DTables.jl @@ -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 From 85331ee94254218acf26b07119a7e6d6d3a00404 Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Sun, 13 Aug 2023 21:28:34 +0530 Subject: [PATCH 3/8] added pretty printing for dtable --- src/table/dtable.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/table/dtable.jl b/src/table/dtable.jl index ce96fe7..70a1b2f 100644 --- a/src/table/dtable.jl +++ b/src/table/dtable.jl @@ -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,fetch(d)) return nothing end From e3d738d386009e82c9553ac7031d4d094d03aa2a Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Mon, 14 Aug 2023 19:33:57 +0530 Subject: [PATCH 4/8] fixed formatting --- src/table/dtable.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/table/dtable.jl b/src/table/dtable.jl index 70a1b2f..b98a363 100644 --- a/src/table/dtable.jl +++ b/src/table/dtable.jl @@ -246,7 +246,7 @@ 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") println(io, "Tabletype: $tabletype") - pretty_table(io,fetch(d)) + pretty_table(io, fetch(d)) return nothing end From c16c0fa6c6a4e3c1881d21a92fb306be5f3f29fd Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Wed, 16 Aug 2023 08:56:41 +0530 Subject: [PATCH 5/8] use suggestion Co-authored-by: Julian Samaroo --- src/table/dtable.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/table/dtable.jl b/src/table/dtable.jl index b98a363..2f6d7ab 100644 --- a/src/table/dtable.jl +++ b/src/table/dtable.jl @@ -246,7 +246,7 @@ 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") println(io, "Tabletype: $tabletype") - pretty_table(io, fetch(d)) + pretty_table(io, d) return nothing end From aa61ecd47168245ce73ead1649c9e00ff159c085 Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Tue, 22 Aug 2023 09:36:22 +0530 Subject: [PATCH 6/8] add pretty print for gdtable --- src/table/gdtable.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/table/gdtable.jl b/src/table/gdtable.jl index 9a436f6..dfccbb6 100644 --- a/src/table/gdtable.jl +++ b/src/table/gdtable.jl @@ -129,7 +129,8 @@ function show(io::IO, ::MIME"text/plain", gd::GDTable) grouped_by_cols = gd.cols === nothing ? string(gd.grouping_function) : grouped_cols(gd) println(io, "GDTable with $(nchunks(gd)) partitions and $(length(gd)) keys") println(io, "Tabletype: $tabletype") - print(io, "Grouped by: $grouped_by_cols") + println(io, "Grouped by: $grouped_by_cols") + pretty_table(io, gd) return nothing end From 1e711a179ab287a7f0476813636901e67fb4b5cd Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Mon, 4 Sep 2023 16:24:23 +0530 Subject: [PATCH 7/8] better pretty print for gdtable --- src/table/gdtable.jl | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/table/gdtable.jl b/src/table/gdtable.jl index dfccbb6..83a7b63 100644 --- a/src/table/gdtable.jl +++ b/src/table/gdtable.jl @@ -130,7 +130,44 @@ function show(io::IO, ::MIME"text/plain", gd::GDTable) println(io, "GDTable with $(nchunks(gd)) partitions and $(length(gd)) keys") println(io, "Tabletype: $tabletype") println(io, "Grouped by: $grouped_by_cols") - pretty_table(io, gd) + + function keyshow(gd, key) + if gd.cols === nothing # grouping function is being used + "Function $(gd.grouping_function) = $key" + elseif typeof(key)<:NamedTuple # multi column case + s = "" + for x in keys(key) + s*="$x = $(key[x]), " + end + s = s[1:end-2] # remove last comma + return s + else # single column case + "$(gd.cols[1]) = $key" + end + end + + function print_group(io, gd, key; prefix = "", suffix = "") # print a single group + d = gd[key] + println(io, "$(prefix)Group$(suffix) ($(length(d)) rows): $(keyshow(gd,key))") + pretty_table(io, d) + return nothing + end + + sorted_keys = sort(collect(keys(gd))) + if !get(io, :limit, false) + ctr = 1 + for key in sorted_keys + print_group(io, gd, key, suffix=" $(ctr)") + ctr+=1 + end + else + fst, lst = first(sorted_keys), last(sorted_keys) + print_group(io, gd, fst, prefix="First ") + if fst!=lst + println(io, "⋮") + print_group(io, gd, lst, prefix="Last ") + end + end return nothing end From 217aafc3045d2c2ce2228916d24bd74704c19f13 Mon Sep 17 00:00:00 2001 From: harsharora21 Date: Mon, 4 Sep 2023 16:34:15 +0530 Subject: [PATCH 8/8] fixed formatting --- src/table/gdtable.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/table/gdtable.jl b/src/table/gdtable.jl index 83a7b63..f0c09e9 100644 --- a/src/table/gdtable.jl +++ b/src/table/gdtable.jl @@ -130,23 +130,23 @@ function show(io::IO, ::MIME"text/plain", gd::GDTable) println(io, "GDTable with $(nchunks(gd)) partitions and $(length(gd)) keys") println(io, "Tabletype: $tabletype") println(io, "Grouped by: $grouped_by_cols") - + function keyshow(gd, key) if gd.cols === nothing # grouping function is being used "Function $(gd.grouping_function) = $key" - elseif typeof(key)<:NamedTuple # multi column case + elseif typeof(key) <: NamedTuple # multi column case s = "" for x in keys(key) - s*="$x = $(key[x]), " + s *= "$x = $(key[x]), " end - s = s[1:end-2] # remove last comma + s = s[1:(end - 2)] # remove last comma return s else # single column case "$(gd.cols[1]) = $key" end end - function print_group(io, gd, key; prefix = "", suffix = "") # print a single group + function print_group(io, gd, key; prefix="", suffix="") # print a single group d = gd[key] println(io, "$(prefix)Group$(suffix) ($(length(d)) rows): $(keyshow(gd,key))") pretty_table(io, d) @@ -157,15 +157,15 @@ function show(io::IO, ::MIME"text/plain", gd::GDTable) if !get(io, :limit, false) ctr = 1 for key in sorted_keys - print_group(io, gd, key, suffix=" $(ctr)") - ctr+=1 + print_group(io, gd, key; suffix=" $(ctr)") + ctr += 1 end else fst, lst = first(sorted_keys), last(sorted_keys) - print_group(io, gd, fst, prefix="First ") - if fst!=lst + print_group(io, gd, fst; prefix="First ") + if fst != lst println(io, "⋮") - print_group(io, gd, lst, prefix="Last ") + print_group(io, gd, lst; prefix="Last ") end end return nothing