Skip to content

daft.functions.not_null#

not_null #

not_null(expr: Expression) -> Expression

Checks if values in the Expression are not Null (a special value indicating missing data).

Returns:

Name Type Description
Expression Boolean Expression

expression indicating whether values are not missing

Examples:

1
2
3
4
5
6
>>> import daft
>>> from daft.functions import not_null
>>>
>>> df = daft.from_pydict({"x": [1.0, None, float("nan")]})
>>> df = df.select(not_null(df["x"]))
>>> df.collect()
╭───────╮
│ x     │
│ ---   │
│ Bool  │
╞═══════╡
│ true  │
├╌╌╌╌╌╌╌┤
│ false │
├╌╌╌╌╌╌╌┤
│ true  │
╰───────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/misc.py
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
def not_null(expr: Expression) -> Expression:
    """Checks if values in the Expression are not Null (a special value indicating missing data).

    Returns:
        Expression (Boolean Expression): expression indicating whether values are not missing

    Examples:
        >>> import daft
        >>> from daft.functions import not_null
        >>>
        >>> df = daft.from_pydict({"x": [1.0, None, float("nan")]})
        >>> df = df.select(not_null(df["x"]))
        >>> df.collect()
        ╭───────╮
        │ x     │
        │ ---   │
        │ Bool  │
        ╞═══════╡
        │ true  │
        ├╌╌╌╌╌╌╌┤
        │ false │
        ├╌╌╌╌╌╌╌┤
        │ true  │
        ╰───────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

    """
    expr = Expression._to_expression(expr)
    return Expression._from_pyexpr(expr._expr.not_null())