[go: up one dir, main page]

Skip to content

daft.functions.space#

space #

space(expr: Expression) -> Expression

Returns a string consisting of n space characters.

This is compatible with Spark's space function.

Parameters:

Name Type Description Default
expr Expression

An integer expression representing the number of spaces

required

Returns:

Name Type Description
Expression Expression

a String expression with n spaces

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import space
>>> df = daft.from_pydict({"x": [1, 3, 5]})
>>> df = df.select(space(df["x"]))
>>> df.show()
╭────────╮
│ x      │
│ ---    │
│ String │
╞════════╡
│        │
├╌╌╌╌╌╌╌╌┤
│        │
├╌╌╌╌╌╌╌╌┤
│        │
╰────────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/str.py
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
def space(expr: Expression) -> Expression:
    """Returns a string consisting of n space characters.

    This is compatible with Spark's space function.

    Args:
        expr: An integer expression representing the number of spaces

    Returns:
        Expression: a String expression with n spaces

    Examples:
        >>> import daft
        >>> from daft.functions import space
        >>> df = daft.from_pydict({"x": [1, 3, 5]})
        >>> df = df.select(space(df["x"]))
        >>> df.show()
        ╭────────╮
        │ x      │
        │ ---    │
        │ String │
        ╞════════╡
        │        │
        ├╌╌╌╌╌╌╌╌┤
        │        │
        ├╌╌╌╌╌╌╌╌┤
        │        │
        ╰────────╯
        <BLANKLINE>
        (Showing first 3 of 3 rows)

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