This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-29
Channels
- # announcements (6)
- # babashka (23)
- # beginners (15)
- # biff (15)
- # calva (17)
- # clara (5)
- # clj-kondo (41)
- # cljdoc (2)
- # cljs-dev (67)
- # cljsrn (18)
- # clojure (19)
- # clojure-europe (25)
- # clojure-nl (2)
- # clojure-norway (9)
- # clojure-uk (2)
- # clojurescript (26)
- # core-typed (6)
- # cursive (15)
- # data-science (30)
- # datahike (1)
- # datomic (18)
- # docker (6)
- # emacs (10)
- # events (2)
- # graalvm (15)
- # graphql (5)
- # hugsql (4)
- # jobs-discuss (1)
- # joker (7)
- # lsp (36)
- # malli (28)
- # off-topic (46)
- # other-languages (1)
- # pathom (5)
- # pedestal (6)
- # polylith (5)
- # reitit (2)
- # releases (1)
- # rewrite-clj (63)
- # shadow-cljs (7)
- # spacemacs (16)
- # squint (6)
- # tools-deps (6)
- # xtdb (13)
How do I get an individual field with tablecloth? I can only seem to narrow it down to a Column
with 1 value
What do you mean by 'individual field'? Dataset is a 2D table. Columns have names, rows have consecutive numbers.
(type (get (tc/last data) "final-column-name"))
=> tech.v3.dataset.impl.column.Column
What am I missing?And please correct my wording, if that's not called a field what is it more commonly called in tabular data?
tc/last
returns a dataset with one row (the last one). get
returns a column which a seq
Is the process we've outlined the canonical way of getting the artist formerly known as "field?"
There is no such function. You always end up with a column (a seq) or a row (as a map). Both are Clojure structures which you know how to deal with.
Adding a specific function might be overkill, but maybe it needs to be a use case in the docs. If you have a general idea where it should be, I could add something if you like
There is a section under dataset
part which deals with accessing rows and cols in general. There can be a function like (tc/get dataset column row)
pluck
, select-item
, retrieve-item
perhaps. I actually thought tc/select
was going to do it given its signature at first glance
Most of the functions in TC returns a dataset. Some of them escape to the clojure structures.
(def ds (tc/dataset {:a [1 2 3]
:b [99 98 97]
:c [:r :t :y]}))
(tc/rows ds) ;; returns vector of rows as vectors
;; => [[1 99 :r] [2 98 :t] [3 97 :y]]
(tc/rows ds :as-maps) ;; returns vector of rows as columns
;; => [{:a 1, :b 99, :c :r} {:a 2, :b 98, :c :t} {:a 3, :b 97, :c :y}]
(tc/columns ds) ;; returns sequence of columns
;; => [#tech.v3.dataset.column<int64>[3]
;; :a
;; [1, 2, 3] #tech.v3.dataset.column<int64>[3]
;; :b
;; [99, 98, 97] #tech.v3.dataset.column<keyword>[3]
;; :c
;; [:r, :t, :y]]
(tc/column ds :c) ;; returns column
;; => #tech.v3.dataset.column<keyword>[3]
;; :c
;; [:r, :t, :y]
;; column is a sequence
(seqable? (tc/column ds :c)) ;; => true
(first (tc/column ds :c)) ;; => :r
;; column is a vector
(sequential? (tc/column ds :c)) ;; => true
((tc/column ds :c) 0) ;; => :r
I don't know why get-in
doesn't work and probably this would be the best path for the data field selector.
Ok, filled an issue for TMD to enable get-in
https://github.com/techascent/tech.ml.dataset/issues/324
I think it would be useful to read the walkthrough and the quick reference- https://techascent.github.io/tech.ml.dataset/walkthrough.html https://techascent.github.io/tech.ml.dataset/quick-reference.html
I think it would be great to have a fn along the lines of get-value
or get-entry
Latest TMD does now support (issue above is fixed):
(get-in ds [cname field-idx])
tablecloth
6.101
landed on clojars with get-entry
added https://scicloj.github.io/tablecloth/index.html#Single_entry


Kickass! Thanks @UDRJMEFSN @U1EP3BZ3Q!
Just published new draft 0.29.0 of Deep Learning for Programmers 2.0. All existing v1.0 subscibers also get all these new updates. https://aiprobook.com/deep-learning-for-programmers/?release=0.30.0
