polars.Expr.str.strip_suffix#
- Expr.str.strip_suffix(suffix: IntoExpr) Expr[source]#
Remove suffix.
The suffix will be removed from the string exactly once, if found.
Note
This method strips the exact character sequence provided in
suffixfrom the end of the input. To strip a set of characters in any order, usestrip_chars_end()instead.- Parameters:
- suffix
The suffix to be removed.
See also
Examples
>>> df = pl.DataFrame({"a": ["foobar", "foobarbar", "foo", "bar"]}) >>> df.with_columns(pl.col("a").str.strip_suffix("bar").alias("stripped")) shape: (4, 2) ┌───────────┬──────────┐ │ a ┆ stripped │ │ --- ┆ --- │ │ str ┆ str │ ╞═══════════╪══════════╡ │ foobar ┆ foo │ │ foobarbar ┆ foobar │ │ foo ┆ foo │ │ bar ┆ │ └───────────┴──────────┘