Skip to content

daft.functions.list_bool_or#

list_bool_or #

list_bool_or(list_expr: Expression) -> Expression

Calculates the boolean OR of all values in a list.

For each list: - Returns True if any non-null value is True - Returns False if all non-null values are False - Returns null if the list is empty or contains only null values

Parameters:

Name Type Description Default
list_expr List Expression

expression to calculate the boolean OR of.

required

Returns:

Name Type Description
Expression Boolean Expression

an expression with the result of the boolean OR operation.

Examples:

1
2
3
4
>>> import daft
>>> from daft.functions import list_bool_or
>>> df = daft.from_pydict({"values": [[True, False], [False, False], [None, None], []]})
>>> df.with_column("result", list_bool_or(df["values"])).collect()
╭────────────────┬────────╮
│ values         ┆ result │
│ ---            ┆ ---    │
│ List[Bool]     ┆ Bool   │
╞════════════════╪════════╡
│ [true, false]  ┆ true   │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ [false, false] ┆ false  │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ [None, None]   ┆ None   │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
│ []             ┆ None   │
╰────────────────┴────────╯
(Showing first 4 of 4 rows)
Source code in daft/functions/list.py
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
def list_bool_or(list_expr: Expression) -> Expression:
    """Calculates the boolean OR of all values in a list.

    For each list:
    - Returns True if any non-null value is True
    - Returns False if all non-null values are False
    - Returns null if the list is empty or contains only null values

    Args:
        list_expr (List Expression): expression to calculate the boolean OR of.

    Returns:
         Expression (Boolean Expression): an expression with the result of the boolean OR operation.

    Examples:
        >>> import daft
        >>> from daft.functions import list_bool_or
        >>> df = daft.from_pydict({"values": [[True, False], [False, False], [None, None], []]})
        >>> df.with_column("result", list_bool_or(df["values"])).collect()
        ╭────────────────┬────────╮
        │ values         ┆ result │
        │ ---            ┆ ---    │
        │ List[Bool]     ┆ Bool   │
        ╞════════════════╪════════╡
        │ [true, false]  ┆ true   │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
        │ [false, false] ┆ false  │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
        │ [None, None]   ┆ None   │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
        │ []             ┆ None   │
        ╰────────────────┴────────╯
        <BLANKLINE>
        (Showing first 4 of 4 rows)
    """
    return Expression._call_builtin_scalar_fn("list_bool_or", list_expr)