otp.Operation.str.find#
- find(sub)#
Find the index of
sub
in the string. If not found, returns-1
.- Parameters
- Returns
The starting position of
sub
or-1
if not found.- Return type
Examples
>>> data = otp.Ticks(X=["ananas", "banana", "potato"]) >>> data["Y"] = data["X"].str.find("ana") >>> otp.run(data)["Y"] 0 0 1 1 2 -1 Name: Y, dtype: int64
>>> data = otp.Ticks(X=["Ananas", "Banana", "Potato"], sub=["Ana", "anan", "ato"]) >>> data["Y"] = data["X"].str.find(data["sub"]) >>> otp.run(data)["Y"] 0 0 1 1 2 3 Name: Y, dtype: int64
Empty string is present in any string
>>> data = otp.Ticks(X=["string", ""]) >>> data["Y"] = data["X"].str.find("") >>> otp.run(data)["Y"] 0 0 1 0 Name: Y, dtype: int64