- DataArray.str.replace(pat, repl, n=-1, case=None, flags=0, regex=True)[source]#
Replace occurrences of pattern/regex in the array with some string.
If pat, repl, or ‘n` is array-like, they are broadcast against the array and applied elementwise.
re.Patternor array-like of
re.Pattern) – String can be a character sequence or regular expression. If array-like, it is broadcast.
callable()or array-like of
callable()) – Replacement string or a callable. The callable is passed the regex match object and must return a replacement string to be used. See
re.sub(). If array-like, it is broadcast.
intor array of
-1) – Number of replacements to make from start. Use
-1to replace all. If array-like, it is broadcast.
True) – If True, case sensitive. Cannot be set if pat is a compiled regex. Equivalent to setting the re.IGNORECASE flag.
0) – Flags to pass through to the re module, e.g. re.IGNORECASE. see compilation-flags.
0means no flags. Flags can be combined with the bitwise or operator
|. Cannot be set if pat is a compiled regex.
True) – If True, assumes the passed-in pattern is a regular expression. If False, treats the pattern as a literal string. Cannot be set to False if pat is a compiled regex or repl is a callable.
same type as values) – A copy of the object with all matching occurrences of pat replaced by repl.