otp.Operation.str.replace#

replace(pat, repl)#

Search for occurrences (case dependent) of pat and replace with repl.

Parameters
Returns

String with pat replaced by repl.

Return type

Operation

Examples

>>> data = otp.Ticks(X=["A Table", "A Chair", "An Apple"])
>>> data["X"] = data["X"].str.replace("A", "The")
>>> otp.run(data)["X"]
0       The Table
1       The Chair
2    Then Thepple
Name: X, dtype: object
>>> data = otp.Ticks(X=["A Table", "A Chair", "An Apple"],
...                  PAT=["A", "A", "An"],
...                  REPL=["The", "Their", "My"])
>>> data["X"] = data["X"].str.replace(data["PAT"], data["REPL"])
>>> otp.run(data)["X"]
0      The Table
1    Their Chair
2       My Apple
Name: X, dtype: object