This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-24
Channels
- # announcements (7)
- # babashka (5)
- # babashka-sci-dev (20)
- # beginners (125)
- # biff (98)
- # catalyst (1)
- # clerk (37)
- # clj-kondo (6)
- # clojure (49)
- # clojure-dev (18)
- # clojure-europe (6)
- # clojure-uk (2)
- # data-science (17)
- # deps-new (20)
- # emacs (11)
- # helix (5)
- # hyperfiddle (34)
- # malli (3)
- # missionary (4)
- # reitit (4)
- # sci (15)
- # solo-full-stack (7)
- # sql (5)
- # testing (2)
For tablecloth.api/select-rows
, what are the valid options
?
tablecloth.api/select-rows
[ds]
[ds rows-selector]
[ds rows-selector options]
Select rows using:
- row id
- seq of row ids
- seq of true/false
- fn with predicate
(defonce flights (tc/dataset ""))
(tc/select-rows flights #(> (get % "dep_delay") 1000))
;; => [8 11]:
;; | year | month | day | dep_delay | arr_delay | carrier | origin | dest | air_time | distance | hour |
;; |-----:|------:|----:|----------:|----------:|---------|--------|------|---------:|---------:|-----:|
;; | 2014 | 2 | 15 | 1003 | 994 | DL | JFK | DEN | 242 | 1626 | 12 |
;; | 2014 | 2 | 21 | 1014 | 1007 | DL | JFK | MCO | 139 | 944 | 8 |
;; | 2014 | 4 | 15 | 1241 | 1223 | AA | JFK | BOS | 39 | 187 | 13 |
;; | 2014 | 6 | 13 | 1071 | 1064 | AA | EWR | DFW | 175 | 1372 | 10 |
;; | 2014 | 6 | 16 | 1022 | 1073 | AA | EWR | DFW | 178 | 1372 | 7 |
;; | 2014 | 7 | 14 | 1087 | 1090 | DL | EWR | ATL | 97 | 746 | 8 |
;; | 2014 | 9 | 12 | 1056 | 1115 | AA | EWR | DFW | 198 | 1372 | 6 |
;; | 2014 | 10 | 4 | 1498 | 1494 | AA | EWR | DFW | 200 | 1372 | 7 |
(tc/select-rows flights #(> (get % "dep_delay") 1000) {:result-type :as-indexes})
;; => (32306 37131 82591 131877 134039 158830 211512 230042)
(tc/select-rows flights '(32306 37131 82591 131877 134039 158830 211512 230042))
;; => [8 11]:
;; | year | month | day | dep_delay | arr_delay | carrier | origin | dest | air_time | distance | hour |
;; |-----:|------:|----:|----------:|----------:|---------|--------|------|---------:|---------:|-----:|
;; | 2014 | 2 | 15 | 1003 | 994 | DL | JFK | DEN | 242 | 1626 | 12 |
;; | 2014 | 2 | 21 | 1014 | 1007 | DL | JFK | MCO | 139 | 944 | 8 |
;; | 2014 | 4 | 15 | 1241 | 1223 | AA | JFK | BOS | 39 | 187 | 13 |
;; | 2014 | 6 | 13 | 1071 | 1064 | AA | EWR | DFW | 175 | 1372 | 10 |
;; | 2014 | 6 | 16 | 1022 | 1073 | AA | EWR | DFW | 178 | 1372 | 7 |
;; | 2014 | 7 | 14 | 1087 | 1090 | DL | EWR | ATL | 97 | 746 | 8 |
;; | 2014 | 9 | 12 | 1056 | 1115 | AA | EWR | DFW | 198 | 1372 | 6 |
;; | 2014 | 10 | 4 | 1498 | 1494 | AA | EWR | DFW | 200 | 1372 | 7 |
:pre
and :parallel
has a meaning only for grouped dataset, :select-keys
can be used to limit keys passed to a selecting function, it can help during processing a dataset with a lot of columns.
good to call @UDRJMEFSN here
@UDRJMEFSN See the last message in the thread.