Skip to content

daft.functions.list_count#

list_count #

list_count(list_expr: Expression, mode: Literal['all', 'valid', 'null'] | CountMode = Valid) -> Expression

Counts the number of elements in each list.

Parameters:

Name Type Description Default
list_expr List Expression

The list expression to count elements of.

required
mode str | CountMode, default=CountMode.Valid

A string ("all", "valid", or "null") that represents whether to count all values, non-null (valid) values, or null values. Defaults to "valid".

Valid

Returns:

Name Type Description
Expression UInt64 Expression

an expression which is the length of each list

Source code in daft/functions/list.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def list_count(
    list_expr: Expression, mode: Literal["all", "valid", "null"] | CountMode = CountMode.Valid
) -> Expression:
    """Counts the number of elements in each list.

    Args:
        list_expr (List Expression): The list expression to count elements of.
        mode (str | CountMode, default=CountMode.Valid):
            A string ("all", "valid", or "null") that represents whether to count all values, non-null (valid) values, or null values. Defaults to "valid".

    Returns:
        Expression (UInt64 Expression): an expression which is the length of each list
    """
    return Expression._call_builtin_scalar_fn("list_count", list_expr, mode=mode)