any

Syntax

any(X)

Parameters

X is a scalar/pair/vector/matrix.

Details

Return 1 if there is at least one element in X that is true or not 0. Null values are ignored.

Differences from Python’s any and numpy.any: Python’s any checks whether any element in an iterable is truthy, returns False for an empty iterable, and returns once it finds the first truthy element. numpy.any can reduce along axis, supports out, keepdims, and where, and treats NaN and infinities as true values. DolphinDB’s any checks whether a scalar, pair, vector, or matrix contains true or non-zero elements, does not provide an axis argument, reduces the input as a whole to a single Boolean value, and ignores NULL values.

Examples

any(1 0 2)
// output: 1

any(0 0 0)
// output: 0

any(0 0 NULL)
// output: 0

any(true false)
// output: 1

any(false false)
// output: 0

any(0..9$2:5)
// output: 1

Related function: all