Skip to content

daft.functions.lstrip#

lstrip #

lstrip(expr: Expression) -> Expression

Strip whitespace from the left side of a UTF-8 string.

Returns:

Name Type Description
Expression Expression

a String expression which is self with leading whitespace stripped

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import lstrip
>>> df = daft.from_pydict({"x": ["foo", "bar", "  baz"]})
>>> df = df.select(lstrip(df["x"]))
>>> df.show()
╭────────╮
│ x      │
│ ---    │
│ String │
╞════════╡
│ foo    │
├╌╌╌╌╌╌╌╌┤
│ bar    │
├╌╌╌╌╌╌╌╌┤
│ baz    │
╰────────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/str.py
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
def lstrip(expr: Expression) -> Expression:
    """Strip whitespace from the left side of a UTF-8 string.

    Returns:
        Expression: a String expression which is `self` with leading whitespace stripped

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

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