Tablecloth Column API
Tablecloth Column API
(column)
(column data)
(column data {:keys [name] :as options})
Create a column
from a vector or sequence.
Create a `column` from a vector or sequence.
(column-map col map-fn)
(column-map col map-fn options)
Applies a map function map-fn
to one or more columns. If col
is
a vector of columns, map-fn
must have an arity equal to the number
of columns. The datatype of the resulting column will be inferred,
unless specified in the options
map. Missing values can be handled
by providing a :missing-fn
in the options map.
options:
Applies a map function `map-fn` to one or more columns. If `col` is a vector of columns, `map-fn` must have an arity equal to the number of columns. The datatype of the resulting column will be inferred, unless specified in the `options` map. Missing values can be handled by providing a `:missing-fn` in the options map. options: - :datatype - The desired datatype of the resulting column. The datatype is inferred if not provided - :missing-fn - A function that takes a sequence of columns, and returns a set of missing index positions.
(column? item)
Return true or false item
is a column.
Return true or false `item` is a column.
(count-missing col)
Returns the number of missing values in column col
.
Returns the number of missing values in column `col`.
(cummax x)
(cummax x options)
Cumulative running max; returns result in double space.
Options:
:nan-strategy
- one of :keep
, :remove
, :exception
. Defaults to :remove
.Cumulative running max; returns result in double space. Options: * `:nan-strategy` - one of `:keep`, `:remove`, `:exception`. Defaults to `:remove`.
(cummin x)
(cummin x options)
Cumulative running min; returns result in double space.
Options:
:nan-strategy
- one of :keep
, :remove
, :exception
. Defaults to :remove
.Cumulative running min; returns result in double space. Options: * `:nan-strategy` - one of `:keep`, `:remove`, `:exception`. Defaults to `:remove`.
(cumprod x)
(cumprod x options)
Cumulative running product; returns result in double space.
Options:
:nan-strategy
- one of :keep
, :remove
, :exception
. Defaults to :remove
.Cumulative running product; returns result in double space. Options: * `:nan-strategy` - one of `:keep`, `:remove`, `:exception`. Defaults to `:remove`.
(cumsum x)
(cumsum x options)
Cumulative running summation; returns result in double space.
Options:
:nan-strategy
- one of :keep
, :remove
, :exception
. Defaults to :remove
.Cumulative running summation; returns result in double space. Options: * `:nan-strategy` - one of `:keep`, `:remove`, `:exception`. Defaults to `:remove`.
(descriptive-statistics x)
(descriptive-statistics x stats-names)
(descriptive-statistics x stats-names options)
(descriptive-statistics x stats-names stats-data options)
Calculate a set of descriptive statistics on a single reader.
Available stats: #{:min :quartile-1 :sum :mean :mode :median :quartile-3 :max :variance :standard-deviation :skew :n-elems :kurtosis}
options
:nan-strategy
- defaults to :remove, one of
[:keep :remove :exception]. The fastest option is :keep but this
may result in your results having NaN's in them. You can also pass
in a double predicate to filter custom double values.Calculate a set of descriptive statistics on a single reader. Available stats: #{:min :quartile-1 :sum :mean :mode :median :quartile-3 :max :variance :standard-deviation :skew :n-elems :kurtosis} options - `:nan-strategy` - defaults to :remove, one of [:keep :remove :exception]. The fastest option is :keep but this may result in your results having NaN's in them. You can also pass in a double predicate to filter custom double values.
(drop-missing col)
Remove missing values from column col
.
Remove missing values from column `col`.
(fill-range x max-span)
Given a reader of numeric data and a max span amount, produce a new reader where the difference between any two consecutive elements is less than or equal to the max span amount. Also return a bitmap of the added indexes. Uses linear interpolation to fill in areas, operates in double space. Returns {:result :missing}
Given a reader of numeric data and a max span amount, produce a new reader where the difference between any two consecutive elements is less than or equal to the max span amount. Also return a bitmap of the added indexes. Uses linear interpolation to fill in areas, operates in double space. Returns {:result :missing}
(is-missing? col idx)
Return true if this index is missing.
Return true if this index is missing.
(mean-fast x)
Take the mean of the x. This operation doesn't know anything about nan hence it is
a bit faster than the base mean
fn.
Take the mean of the x. This operation doesn't know anything about nan hence it is a bit faster than the base [[mean]] fn.
(missing col)
Indexes of missing values. Both iterable and reader.
Indexes of missing values. Both iterable and reader.
(ones n-ones)
Creates a new column filled with n-ones
Creates a new column filled with `n-ones`
(percentiles x percentages)
(percentiles x percentages options)
Create a reader of percentile values, one for each percentage passed in. Estimation types are in the set of #{:r1,r2...legacy} and are described here: https://commons.apache.org/proper/commons-math/javadocs/api-3.3/index.html.
nan-strategy can be one of [:keep :remove :exception] and defaults to :exception.
Create a reader of percentile values, one for each percentage passed in. Estimation types are in the set of #{:r1,r2...legacy} and are described here: https://commons.apache.org/proper/commons-math/javadocs/api-3.3/index.html. nan-strategy can be one of [:keep :remove :exception] and defaults to :exception.
(quartiles x)
(quartiles x options)
return [min, 25 50 75 max] of item
return [min, 25 50 75 max] of item
(replace-missing col)
(replace-missing col strategy)
(replace-missing col strategy value)
Replace missing values in column col
with give strategy
.
Strategies may be:
:down
- Take the previous value, or use provided value.:up
- Take the next value, or use provided value.:downup
- Take the previous value, otherwise take the next value.:updown
- Take the next value, otherwise take the previous value.:nearest
- Use the nearest of next or previous values. (Strategy :mid
is an alias for :nearest
).:midpoint
- Use the midpoint of averaged values between previous and next (non-missing) values.:abb
- Impute missing value with approximate Bayesian bootstrap.
See r's ABB.:lerp
- Linearly interpolate values between previous and next nonmissing rows.:value
- Provide a value explicitly. Value may be a function in which
case it will be called on the column with missing values elided
and the return will be used to as the filler.Replace missing values in column `col` with give `strategy`. Strategies may be: - `:down` - Take the previous value, or use provided value. - `:up` - Take the next value, or use provided value. - `:downup` - Take the previous value, otherwise take the next value. - `:updown` - Take the next value, otherwise take the previous value. - `:nearest` - Use the nearest of next or previous values. (Strategy `:mid` is an alias for `:nearest`). - `:midpoint` - Use the midpoint of averaged values between previous and next (non-missing) values. - `:abb` - Impute missing value with approximate Bayesian bootstrap. See [r's ABB](https://search.r-project.org/CRAN/refmans/LaplacesDemon/html/ABB.html). - `:lerp` - Linearly interpolate values between previous and next nonmissing rows. - `:value` - Provide a value explicitly. Value may be a function in which case it will be called on the column with missing values elided and the return will be used to as the filler.
(round x)
(round x options)
Vectorized implementation of Math/round. Operates in double space but returns a long or long reader.
Vectorized implementation of Math/round. Operates in double space but returns a long or long reader.
(select col selection)
Return a new column with the subset of indexes based on the provided selection
.
selection
can be a list of indexes to select or boolean values where the index
position of each true element indicates a index to select. When supplying a list
of indices, duplicates are possible and will select the specified position more
than once.
Return a new column with the subset of indexes based on the provided `selection`. `selection` can be a list of indexes to select or boolean values where the index position of each true element indicates a index to select. When supplying a list of indices, duplicates are possible and will select the specified position more than once.
(shift x n)
Shift by n and fill in with the first element for n>0 or last element for n<0.
Examples:
user> (dfn/shift (range 10) 2)
[0 0 0 1 2 3 4 5 6 7]
user> (dfn/shift (range 10) -2)
[2 3 4 5 6 7 8 9 9 9]
Shift by n and fill in with the first element for n>0 or last element for n<0. Examples: ```clojure user> (dfn/shift (range 10) 2) [0 0 0 1 2 3 4 5 6 7] user> (dfn/shift (range 10) -2) [2 3 4 5 6 7 8 9 9 9] ```
(slice col from)
(slice col from to)
(slice col from to step)
Returns a subset of the column defined by the inclusive from
and
to
indexes. If to
is not provided, slices to the end of the
column. If from
is not provided (i.e. is nil
), slices from the
beginning of the column. If either from
or to
is a negative
number, it is treated as an index from the end of the column. The
:start
and :end
keywords can be used to represent the start and
end of the column, respectively.
Examples: (def column [1 2 3 4 5]) (slice column 1 3) ;=> [2 3] (slice column 2) ;=> [3 4 5] (slice column -3 -1) ;=> [3 4 5] (slice column :start 2) ;=> [1 2 3 4 5] (slice column 2 :end) ;=> [3 4 5] (slice column -2 :end) ;=> [4 5]
Returns a subset of the column defined by the inclusive `from` and `to` indexes. If `to` is not provided, slices to the end of the column. If `from` is not provided (i.e. is `nil`), slices from the beginning of the column. If either `from` or `to` is a negative number, it is treated as an index from the end of the column. The `:start` and `:end` keywords can be used to represent the start and end of the column, respectively. Examples: (def column [1 2 3 4 5]) (slice column 1 3) ;=> [2 3] (slice column 2) ;=> [3 4 5] (slice column -3 -1) ;=> [3 4 5] (slice column :start 2) ;=> [1 2 3 4 5] (slice column 2 :end) ;=> [3 4 5] (slice column -2 :end) ;=> [4 5]
(sort-column col)
(sort-column col order-or-comparator)
Returns a sorted version of the column col
. You can supply the ordering
keywords :asc
or :desc
or a comparator function to order-or-comparator
.
If no comparator function is provided, the column will be sorted in
ascending order.
Returns a sorted version of the column `col`. You can supply the ordering keywords `:asc` or `:desc` or a comparator function to `order-or-comparator`. If no comparator function is provided, the column will be sorted in ascending order.
(sum x)
(sum x options)
Double sum of data using Kahan compensated summation.
Double sum of data using [Kahan compensated summation](https://en.wikipedia.org/wiki/Kahan_summation_algorithm).
(sum-fast x)
Find the sum of the data. This operation is neither nan-aware nor does it implement
kahans compensation although via parallelization it implements pairwise summation
compensation. For a more but slightly slower but far more correct sum operator,
use sum
.
Find the sum of the data. This operation is neither nan-aware nor does it implement kahans compensation although via parallelization it implements pairwise summation compensation. For a more but slightly slower but far more correct sum operator, use [[sum]].
(typeof col)
Returns the concrete type of the elements within the column col
.
Returns the concrete type of the elements within the column `col`.
(typeof? col datatype)
True|false the column's elements are of the provided type datatype
. Can check
both concrete types (e.g. :int32) or general types (:numerical, :textual, etc).
True|false the column's elements are of the provided type `datatype`. Can check both concrete types (e.g. :int32) or general types (:numerical, :textual, etc).
(unsigned-bit-shift-right x y)
(unsigned-bit-shift-right x y & args)
(zeros n-zeros)
Create a new column filled wth n-zeros
.
Create a new column filled wth `n-zeros`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close