Module Agg.Bool

Boolean aggregations - work on boolean columns only.

Operations in this module work exclusively with boolean columns. Null values (None in bool option arrays) are handled consistently.

  • raises Invalid_argument

    if column is not boolean type.

val all : t -> string -> bool

all df name returns true if all non-null values are true.

Returns true for empty columns or columns with only null values. This follows the mathematical convention that universal quantification over an empty set is true.

Time complexity: O(n) where n is the number of rows.

val any : t -> string -> bool

any df name returns true if any non-null value is true.

Returns false for empty columns or columns with only null/false values.

Time complexity: O(n) in worst case, but often faster due to short-circuiting.

val sum : t -> string -> int

sum df name returns count of true values.

Treats true as 1 and false as 0, then sums. Null values are excluded from the count.

Time complexity: O(n) where n is the number of rows.

val mean : t -> string -> float

mean df name returns proportion of true values among non-null values.

Equivalent to (count of true values) / (count of non-null values). Returns NaN if all values are null.

Time complexity: O(n) where n is the number of rows.