tabsdata.tableframe.expr.string.ExprStringNameSpace.replace_all#

ExprStringNameSpace.replace_all(pattern: str | Expr, value: str | Expr, *, literal: bool = False) Expr[source]#

Replace the all occurences of a pattern with the given string.

Parameters:
  • pattern – The pattern to replace.

  • value – The value to replace the pattern with.

  • literal – Take the pattern as a literal string (not a regex).

Example:

>>> 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        │
└───────────┴─────────────┘