This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-07
Channels
- # adventofcode (94)
- # babashka (29)
- # babashka-sci-dev (2)
- # beginners (103)
- # calva (15)
- # cider (17)
- # clj-kondo (62)
- # cljsrn (24)
- # clojars (13)
- # clojure (97)
- # clojure-belgium (3)
- # clojure-berlin (3)
- # clojure-czech (1)
- # clojure-europe (68)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojure-seattle (3)
- # clojure-uk (1)
- # clojurescript (7)
- # community-development (29)
- # conjure (2)
- # cursive (14)
- # data-science (15)
- # emacs (3)
- # graphql (10)
- # gratitude (1)
- # holy-lambda (32)
- # hoplon (21)
- # hyperfiddle (2)
- # jobs (2)
- # joyride (36)
- # lsp (4)
- # meander (13)
- # off-topic (203)
- # pathom (3)
- # polylith (6)
- # re-frame (4)
- # reagent (1)
- # reitit (28)
- # releases (1)
- # shadow-cljs (16)
- # slack-help (2)
- # sql (27)
- # vim (2)
Is there any way to make aggregates that produce more than one rows with tablecloth or dataset?
I have a table of user answers, I want to calculate daily progress of each users So I'm grouping by users, order by day and want to produce a row for each day with the aggregation of answers of the day + previous day a wrong answer resets the progress to 1 eg: day 1 t t f -> 1 day 2 t f t t -> 3 day 3 t t -> 5 so I need a reduction on each user (simplifying the problem for the example)
so far I managed to do it by adding a progress column in tablecloth, but I have 2 million answers and for the next step I need to extrapolate the progress to the missing day, the solutions I tried are too slow (didn't let it finish after an hour), a vanilla clojure solution with map and reduce building a vector of n (number of days) elements only took 8 seconds for this dataset, 7 seconds being getting the 2 millions rows from the database with jdbc.next
Tablecloth can aggregate a grouped dataset. So first you apply group-by
and then aggregate
This way you will have aggregation per day. See some examples here: https://scicloj.github.io/tablecloth/index.html#Aggregate
but I need to know the result of the aggregate of the previous day to start the aggregate of each day
Ok... then first approach should be ok, grouping by user, order by day and then custom reduction function.
Tablecloth (TC) operations are very similar to SQL, so if it's hard to do in SQL it can be hard as well in TC.
I guess my issue is that I don't see how you'd do a custom reduction function that lets you replace a dataset subgroup by another
wouldn't work
I want the progress of every day, and it needs to take the previous day into account