Skip to content

daft.functions.is_nan#

is_nan #

is_nan(expr: Expression) -> Expression

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

Returns:

Name Type Description
Expression Expression

Boolean Expression indicating whether values are 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 is_nan
>>>
>>> df = daft.from_pydict({"data": [1.0, None, float("nan")]})
>>> df = df.select(is_nan(df["data"]))
>>> df.collect()
╭───────╮
│ data  │
│ ---   │
│ Bool  │
╞═══════╡
│ false │
├╌╌╌╌╌╌╌┤
│ None  │
├╌╌╌╌╌╌╌┤
│ true  │
╰───────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/numeric.py
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
def is_nan(expr: Expression) -> Expression:
    """Checks if values are NaN (a special float value indicating not-a-number).

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

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

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

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