polars.Expr.str.rstrip#

Expr.str.rstrip(matches: None | str = None) Expr[source]#

Remove trailing whitespace.

Parameters:
matches

An optional single character that should be trimmed

Examples

>>> df = pl.DataFrame({"foo": [" lead", "trail ", " both "]})
>>> df.select(pl.col("foo").str.rstrip())
shape: (3, 1)
┌───────┐
│ foo   │
│ ---   │
│ str   │
╞═══════╡
│  lead │
├╌╌╌╌╌╌╌┤
│ trail │
├╌╌╌╌╌╌╌┤
│  both │
└───────┘