Skip to content

daft.functions.not_nan#

not_nan #

not_nan(expr: Expression) -> Expression

Checks if values are not NaN (a special float value indicating not-a-number).

Returns:

Name Type Description
Expression Expression

Boolean Expression indicating whether values are not invalid.

Note

Nulls will be propagated! I.e. this operation will return a null for null values.

Examples:

1
2
3
4
5
6
>>> import daft
>>> from daft.functions import not_nan
>>>
>>> df = daft.from_pydict({"x": [1.0, None, float("nan")]})
>>> df = df.select(not_nan(df["x"]))
>>> df.collect()
╭───────╮
│ x     │
│ ---   │
│ Bool  │
╞═══════╡
│ true  │
├╌╌╌╌╌╌╌┤
│ None  │
├╌╌╌╌╌╌╌┤
│ false │
╰───────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/numeric.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
def not_nan(expr: Expression) -> Expression:
    """Checks if values are not NaN (a special float value indicating not-a-number).

    Returns:
        Expression: Boolean Expression indicating whether values are not invalid.

    Note:
        Nulls will be propagated! I.e. this operation will return a null for null values.

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

    """
    return Expression._call_builtin_scalar_fn("not_nan", expr)