Liking cljdoc? Tell your friends :D
Clojure only.

tablecloth.time.api.slice


sliceclj

(slice ds time-column-name from to)
(slice ds
       time-column-name
       from
       to
       {:keys [result-type] :or {result-type :as-dataset}})

Returns a subset of dataset's rows between from and to (both inclusive).

The time column is sliced using binary search, so it must be sorted in ascending order.

Arguments:

  • ds: the dataset to slice
  • time-column: keyword or function to select the time column (e.g., :timestamp or ds)
  • from: start time (string, datetime literal, epoch millis, or any temporal type)
  • to: end time (string, datetime literal, epoch millis, or any temporal type)
  • opts: optional map with:
    • :result-type - :as-dataset (default) returns a dataset, :as-indices returns indices

Time values are normalized to epoch milliseconds for comparison. Strings are parsed using ISO-8601 format via tablecloth.time.parse/parse.

Examples:

;; Basic usage with strings (slice ds :timestamp "2024-01-01" "2024-12-31")

;; With datetime literals (requires time-literals data readers) (slice ds :timestamp #time/instant "2024-01-01T00:00:00Z" #time/instant "2024-12-31T23:59:59Z")

;; Return indices instead of dataset (slice ds :timestamp "2024-01-01" "2024-12-31" {:result-type :as-indices})

;; Using epoch milliseconds directly (slice ds :timestamp 1704067200000 1704153599999)

Returns a subset of dataset's rows between `from` and `to` (both inclusive).

The time column is sliced using binary search, so it must be sorted in ascending
order. 

Arguments:
- ds: the dataset to slice
- time-column: keyword or function to select the time column (e.g., :timestamp or ds)
- from: start time (string, datetime literal, epoch millis, or any temporal type)
- to: end time (string, datetime literal, epoch millis, or any temporal type)
- opts: optional map with:
  - :result-type - `:as-dataset` (default) returns a dataset, `:as-indices` returns indices

Time values are normalized to epoch milliseconds for comparison. Strings are parsed
using ISO-8601 format via `tablecloth.time.parse/parse`.

Examples:

  ;; Basic usage with strings
  (slice ds :timestamp "2024-01-01" "2024-12-31")
  
  ;; With datetime literals (requires time-literals data readers)
  (slice ds :timestamp 
         #time/instant "2024-01-01T00:00:00Z" 
         #time/instant "2024-12-31T23:59:59Z")
  
  ;; Return indices instead of dataset
  (slice ds :timestamp "2024-01-01" "2024-12-31" {:result-type :as-indices})
  
  ;; Using epoch milliseconds directly
  (slice ds :timestamp 1704067200000 1704153599999)
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