otp.Operation.str.replace#
- replace(pat, repl)#
Search for occurrences (case dependent) of
pat
and replace withrepl
.- Parameters
- Returns
String with
pat
replaced byrepl
.- Return type
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