tabsdata.tableframe.expr.string.ExprStringNameSpace.replace_many#

ExprStringNameSpace.replace_many(patterns: td_expr.IntoExpr | Mapping[str, str], replace_with: td_expr.IntoExpr | NoDefault = <no_default>, *, ascii_case_insensitive: bool = False) td_expr.Expr[source]#

Replace the all occurences of any the given patterns with the given string.

Parameters:
  • patterns – The patterns to replace.

  • replace_with – The value to replace the pattern with.

  • ascii_case_insensitive – If true, the search is case-insensitive.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("a"), td.col("a")
      .str.replace_many(["a", "b"], "X").alias("replace_many"))
>>>
┌──────┬──────────────┐
│ a    ┆ replace_many │
│ ---  ┆ ---          │
│ str  ┆ str          │
╞══════╪══════════════╡
│ abc  ┆ XXc          │
│ axy  ┆ Xxy          │
│ xyb  ┆ xyX          │
│ xyz  ┆ xyz          │
│ null ┆ null         │
└──────┴──────────────┘