Calculates the boolean OR of all values in the expression.
For each group: - Returns True if any non-null value is True - Returns False if all non-null values are False - Returns null if the group is empty or contains only null values
Examples:
| >>> import daft
>>> from daft.functions import bool_or
>>> df = daft.from_pydict({"a": [False, None, False], "b": [False, True, None], "c": [None, None, None]})
>>> df.agg(bool_or(df["a"]), bool_or(df["b"]), bool_or(df["c"])).show()
|
╭───────┬──────┬──────╮
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ Bool ┆ Bool ┆ Bool │
╞═══════╪══════╪══════╡
│ false ┆ true ┆ None │
╰───────┴──────┴──────╯
(Showing first 1 of 1 rows)
Source code in daft/functions/agg.py
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257 | def bool_or(expr: Expression) -> Expression:
"""Calculates the boolean OR of all values in the expression.
For each group:
- Returns True if any non-null value is True
- Returns False if all non-null values are False
- Returns null if the group is empty or contains only null values
Examples:
>>> import daft
>>> from daft.functions import bool_or
>>> df = daft.from_pydict({"a": [False, None, False], "b": [False, True, None], "c": [None, None, None]})
>>> df.agg(bool_or(df["a"]), bool_or(df["b"]), bool_or(df["c"])).show()
╭───────┬──────┬──────╮
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ Bool ┆ Bool ┆ Bool │
╞═══════╪══════╪══════╡
│ false ┆ true ┆ None │
╰───────┴──────┴──────╯
<BLANKLINE>
(Showing first 1 of 1 rows)
"""
return Expression._from_pyexpr(expr._expr.bool_or())
|