Liking cljdoc? Tell your friends :D

datajure.core


*dt*clj

Holds the last dataset result in an interactive REPL session. Automatically bound by datajure.nrepl/wrap-dt middleware. Like Clojure's *1, but only for tech.v3.dataset results.

Holds the last dataset result in an interactive REPL session.
Automatically bound by datajure.nrepl/wrap-dt middleware.
Like Clojure's *1, but only for tech.v3.dataset results.
sourceraw docstring

ascclj

(asc col)

Sort-spec helper: ascending order on col. Use in :order-by.

Sort-spec helper: ascending order on col. Use in :order-by.
sourceraw docstring

count*clj

(count* col)

Count of non-nil values in a column. Asterisk-suffixed to avoid shadowing clojure.core/count. Distinct from N (total rows) and count-distinct (unique non-nil values).

Count of non-nil values in a column.
Asterisk-suffixed to avoid shadowing `clojure.core/count`.
Distinct from N (total rows) and count-distinct (unique non-nil values).
sourceraw docstring

cutclj

(cut col-kw n)

Equal-count (quantile) binning — assigns each value in a column to a bin in 1..n based on its percentile rank among non-nil values.

Breakpoints are the 100/n, 200/n, ..., (n-1)*100/n percentiles of the non-nil values. Bin assignment is right-open (binarySearch), so every value lands in exactly one bin in [1, n]. nil values produce nil.

Complements xbar (equal-width bins). Use inside #dt/e:

(dt ds :set {:quintile #dt/e (cut :mass 5)}) (dt ds :where #dt/e (= (cut :mass 4) 1)) ;; bottom quartile

Note: cut requires whole-column context and cannot be used as a standalone row-level function in :by. Use #dt/e (cut :col n) for all use cases.

Equal-count (quantile) binning — assigns each value in a column to a bin
in 1..n based on its percentile rank among non-nil values.

Breakpoints are the 100/n, 200/n, ..., (n-1)*100/n percentiles of the
non-nil values. Bin assignment is right-open (binarySearch), so every
value lands in exactly one bin in [1, n]. nil values produce nil.

Complements xbar (equal-width bins). Use inside #dt/e:

  (dt ds :set {:quintile #dt/e (cut :mass 5)})
  (dt ds :where #dt/e (= (cut :mass 4) 1))   ;; bottom quartile

Note: cut requires whole-column context and cannot be used as a standalone
row-level function in :by. Use #dt/e (cut :col n) for all use cases.
sourceraw docstring

descclj

(desc col)

Sort-spec helper: descending order on col. Use in :order-by.

Sort-spec helper: descending order on col. Use in :order-by.
sourceraw docstring

dtclj

(dt dataset & {:keys [where set agg by select order-by within-order]})

Query a dataset. Supported keywords: :where, :set, :agg, :by, :select, :order-by, :within-order.

:where - filter rows. Accepts #dt/e expression or plain fn of row map. :set - derive/update columns. Accepts map or vector-of-pairs. When :set contains win/* functions, window mode is activated — with :by, computes within groups; without :by, whole dataset is one partition. :agg - collapse to summary. Accepts map or vector-of-pairs. Use N for row count. :by - grouping for :agg or :set (partitioned window mode). Vector of keywords or fn of row. :within-order - sort within each partition (or whole dataset) before window computation. Valid with :set (with or without :by). Not valid with :agg. :select - keep columns. Accepts: vector of kws, single kw, [:not kw ...], regex, predicate fn, or map {old-kw new-kw} for rename-on-select. :order-by - sort rows. Accepts a vector of (asc :col)/(desc :col) specs, or bare keywords (default asc). Evaluated after all other steps.

Query a dataset. Supported keywords: :where, :set, :agg, :by, :select, :order-by, :within-order.

:where         - filter rows. Accepts #dt/e expression or plain fn of row map.
:set           - derive/update columns. Accepts map or vector-of-pairs.
                 When :set contains win/* functions, window mode is activated —
                 with :by, computes within groups; without :by, whole dataset is one partition.
:agg           - collapse to summary. Accepts map or vector-of-pairs. Use N for row count.
:by            - grouping for :agg or :set (partitioned window mode). Vector of keywords or fn of row.
:within-order  - sort within each partition (or whole dataset) before window computation.
                 Valid with :set (with or without :by). Not valid with :agg.
:select        - keep columns. Accepts: vector of kws, single kw, [:not kw ...],
                 regex, predicate fn, or map {old-kw new-kw} for rename-on-select.
:order-by      - sort rows. Accepts a vector of (asc :col)/(desc :col) specs,
                 or bare keywords (default asc). Evaluated after all other steps.
sourceraw docstring

max*clj

Column maximum. Full-name alias for dfn/reduce-max. Asterisk-suffixed to avoid shadowing clojure.core/max.

Column maximum. Full-name alias for `dfn/reduce-max`.
Asterisk-suffixed to avoid shadowing `clojure.core/max`.
sourceraw docstring

meanclj

Column mean. Full-name alias for dfn/mean.

Column mean. Full-name alias for `dfn/mean`.
sourceraw docstring

medianclj

Column median. Full-name alias for dfn/median.

Column median. Full-name alias for `dfn/median`.
sourceraw docstring

min*clj

Column minimum. Full-name alias for dfn/reduce-min. Asterisk-suffixed to avoid shadowing clojure.core/min.

Column minimum. Full-name alias for `dfn/reduce-min`.
Asterisk-suffixed to avoid shadowing `clojure.core/min`.
sourceraw docstring

Nclj

Row count aggregation helper. Use as a value in :agg maps.

Row count aggregation helper. Use as a value in :agg maps.
sourceraw docstring

pass-nilclj

(pass-nil f & guard-cols)

Wraps a row-level fn to return nil if any of the specified guard columns are nil/missing in the row. Prevents crashes when plain fns encounter missing values in :set or :where.

Usage: (pass-nil #(Integer/parseInt (:x-str %)) :x-str)

Wraps a row-level fn to return nil if any of the specified guard columns
are nil/missing in the row. Prevents crashes when plain fns encounter
missing values in :set or :where.

Usage: (pass-nil #(Integer/parseInt (:x-str %)) :x-str)
sourceraw docstring

renameclj

(rename dataset col-map)

Rename columns in a dataset without dropping any. col-map is {old-kw new-kw}.

Rename columns in a dataset without dropping any.
col-map is {old-kw new-kw}.
sourceraw docstring

reset-notes!clj

(reset-notes!)

Reset shown info notes. Useful for testing.

Reset shown info notes. Useful for testing.
sourceraw docstring

stddevclj

Column standard deviation. Full-name alias for dfn/standard-deviation.

Column standard deviation. Full-name alias for `dfn/standard-deviation`.
sourceraw docstring

sumclj

Column sum. Full-name alias for dfn/sum.

Column sum. Full-name alias for `dfn/sum`.
sourceraw docstring

varianceclj

Column variance. Full-name alias for dfn/variance.

Column variance. Full-name alias for `dfn/variance`.
sourceraw docstring

xbarclj

(xbar col-kw width)
(xbar col-kw width unit)

Floor-division bucketing — floors a column value to the nearest multiple of width. Inspired by q's xbar operator.

For numeric columns: (xbar :price 10) → floor(:price / 10) * 10 For temporal columns: (xbar :time 5 :minutes) → floor to nearest 5-minute boundary

Supported temporal units: :seconds, :minutes, :hours, :days, :weeks

Primary use case: computed :by grouping for time-series bar generation.

Usage: ;; Numeric bucketing in :by (dt ds :by [(xbar :price 10)] :agg {:n N :avg #dt/e (mn :volume)})

;; 5-minute OHLCV bars (-> trades (dt :order-by [(asc :time)]) (dt :by [(xbar :time 5 :minutes) :sym] :agg {:open #dt/e (first-val :price) :close #dt/e (last-val :price) :vol #dt/e (sm :size) :n N}))

;; Also usable inside #dt/e as a column derivation: (dt ds :set {:bucket #dt/e (xbar :price 5)})

Floor-division bucketing — floors a column value to the nearest multiple of width.
Inspired by q's xbar operator.

For numeric columns: (xbar :price 10) → floor(:price / 10) * 10
For temporal columns: (xbar :time 5 :minutes) → floor to nearest 5-minute boundary

Supported temporal units: :seconds, :minutes, :hours, :days, :weeks

Primary use case: computed :by grouping for time-series bar generation.

Usage:
  ;; Numeric bucketing in :by
  (dt ds :by [(xbar :price 10)] :agg {:n N :avg #dt/e (mn :volume)})

  ;; 5-minute OHLCV bars
  (-> trades
      (dt :order-by [(asc :time)])
      (dt :by [(xbar :time 5 :minutes) :sym]
          :agg {:open  #dt/e (first-val :price)
                :close #dt/e (last-val :price)
                :vol   #dt/e (sm :size)
                :n     N}))

  ;; Also usable inside #dt/e as a column derivation:
  (dt ds :set {:bucket #dt/e (xbar :price 5)})
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close