polars.Expr.str.rjust#

Expr.str.rjust(width: int, fillchar: str = ' ') Expr[source]#

Return the string right justified in a string of length width.

Padding is done using the specified fillchar. The original string is returned if width is less than or equal to len(s).

Parameters:
width

Justify right to this length.

fillchar

Fill with this ASCII character.

Examples

>>> df = pl.DataFrame({"a": ["cow", "monkey", None, "hippopotamus"]})
>>> df.select(pl.col("a").str.rjust(8, "*"))
shape: (4, 1)
┌──────────────┐
│ a            │
│ ---          │
│ str          │
╞══════════════╡
│ *****cow     │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ **monkey     │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ null         │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ hippopotamus │
└──────────────┘