Skip to content

daft.functions.right#

right #

right(expr: Expression, nchars: int | Expression) -> Expression

Gets the n (from nchars) right-most characters of each string.

Returns:

Name Type Description
Expression Expression

a String expression which is the n right-most characters of self

Examples:

1
2
3
4
5
>>> import daft
>>> from daft.functions import right
>>> df = daft.from_pydict({"x": ["daft", "distributed", "engine"]})
>>> df = df.select(right(df["x"], 4))
>>> df.show()
╭────────╮
│ x      │
│ ---    │
│ String │
╞════════╡
│ daft   │
├╌╌╌╌╌╌╌╌┤
│ uted   │
├╌╌╌╌╌╌╌╌┤
│ gine   │
╰────────╯
(Showing first 3 of 3 rows)
Source code in daft/functions/str.py
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
def right(expr: Expression, nchars: int | Expression) -> Expression:
    """Gets the n (from nchars) right-most characters of each string.

    Returns:
        Expression: a String expression which is the `n` right-most characters of `self`

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

    """
    return Expression._call_builtin_scalar_fn("right", expr, nchars)