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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
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)