Skip to content

daft.functions.rstrip#

rstrip #

rstrip(expr: Expression) -> Expression

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

Returns:

Name Type Description
Expression Expression

a String expression which is self with trailing whitespace stripped

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import rstrip
>>> df = daft.from_pydict({"x": ["foo", "bar", "baz   "]})
>>> df = df.select(rstrip(df["x"]))
>>> df.show()
╭────────╮
│ x      │
│ ---    │
│ String │
╞════════╡
│ foo    │
├╌╌╌╌╌╌╌╌┤
│ bar    │
├╌╌╌╌╌╌╌╌┤
│ baz    │
╰────────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/str.py
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
def rstrip(expr: Expression) -> Expression:
    """Strip whitespace from the right side of a UTF-8 string.

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

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

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