Expr.str.replace_all
methodView source ↗
def replace_all(pattern: str | Expr, value: str | Expr, literal: bool = False) -> Expr
Categories: string
Replace the all occurences of a pattern with the given string.
Parameters
parameter
patternThe pattern to replace.
parameter
valueThe value to replace the pattern with.
parameter
literalTake the pattern as a literal string (not a regex).
Examples
>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a").str.replace("b", "X").alias("replace"))
>>>
┌───────────┬─────────────┐
│ a ┆ replace_all │
│ --- ┆ --- │
│ str ┆ str │
╞═══════════╪═════════════╡
│ a bAb c d ┆ a XAX c d │
│ bCbb c d ┆ XCXX c d │
│ bb ┆ XX │
│ b ┆ X │
│ a ┆ a │
│ null ┆ null │
└───────────┴─────────────┘