pyarrow.compute.replace_substring#

pyarrow.compute.replace_substring(strings, /, pattern, replacement, *, max_replacements=None, options=None, memory_pool=None)#

Replace matching non-overlapping substrings with replacement.

For each string in strings, replace non-overlapping substrings that match the given literal pattern with the given replacement. If max_replacements is given and not equal to -1, it limits the maximum amount replacements per input, counted from the left. Null values emit null.

Parameters
stringsArray-like or scalar-like

Argument to compute function.

patternstr

Substring pattern to look for inside input values.

replacementstr

What to replace the pattern with.

max_replacementsint or None, default None

The maximum number of strings to replace in each input value (unlimited if None).

optionspyarrow.compute.ReplaceSubstringOptions, optional

Alternative way of passing options.

memory_poolpyarrow.MemoryPool, optional

If not passed, will allocate memory from the default memory pool.