Skip to main content
Version: 1.9.0

Expr.str.replace_many

def replace_many(
patterns: td_IntoExpr | Mapping[str, str],
replace_with: td_IntoExpr | NoDefault = <no_default>,
ascii_case_insensitive: bool = False,
) -> Expr

Categories: string

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

Parameters

parameter
patterns

The patterns to replace.

parameter
replace_with

The value to replace the pattern with.

parameter
ascii_case_insensitive

If true, the search is case-insensitive.

Examples

>>> 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 │
------
strstr
╞══════╪══════════════╡
│ abc ┆ XXc │
│ axy ┆ Xxy │
│ xyb ┆ xyX │
│ xyz ┆ xyz │
│ null ┆ null │
└──────┴──────────────┘