This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-06
Channels
- # babashka (60)
- # beginners (36)
- # clj-kondo (29)
- # clojure (91)
- # clojure-dev (18)
- # clojure-europe (12)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (5)
- # clojuredesign-podcast (8)
- # clojurescript (40)
- # core-typed (74)
- # data-science (8)
- # datomic (9)
- # emacs (22)
- # events (5)
- # fulcro (56)
- # gratitude (3)
- # hyperfiddle (11)
- # lsp (6)
- # malli (36)
- # meander (23)
- # off-topic (50)
- # polylith (4)
- # portal (10)
- # reitit (4)
- # schema (1)
- # shadow-cljs (66)
- # squint (3)
- # tools-deps (16)
Hey all, I’m watching the amazingly appreciated London Clojurians talk by Kira on Tablecloth. There is something I can’t replicate in the beginning which annoys me to not understand. Basically, it’s about displaying/printing datasets after a group-by. Kira outputs to the repl by just: (starting a couple of lines down):
...
(tc/as-regular-dataset)
(tc/select-rows 0)
:data
But I have to go (full example from the start):
(-> tst2
(tc/group-by [:name])
(tc/as-regular-dataset)
(tc/select-rows 0)
:data
first
tc/print-dataset
)
How would manage to output a sub-dataset without both the extra “first” and the explicit print-dataset call? Some wiring in the background? :thinking_face:😅
Here is the answer!
(-> tst2
(tc/group-by [:name]) ;; creating a grouped dataset
(tc/as-regular-dataset) ;; this removes information about grouping, reveals internal structures
(tc/select-rows 0) ;; selects first row
:data ;; selects a `:data` column, which contains only one element
first ;; a column is a sequence here, that's why we should take the first element...
tc/print-dataset ;; ... which is a some subdataset
)
Regarding the print-dataset
call. It depends how your REPL prints a dataset but imho it's not necessary step here.
print-dataset
just prints a dataset to the *out*
I suppose. Without it above form should return a dataset and let REPL to print it properly.
Announcing the 1st meeting of the Scicloj real-world-data group: https://clojureverse.org/t/real-world-data-meeting-1/