cudf.core.column.string.StringMethods.rindex#

StringMethods.rindex(sub: str, start: int = 0, end: int | None = None) SeriesOrIndex#

Return highest indexes in each strings where the substring is fully contained between [start:end]. This is the same as str.rfind except instead of returning -1, it raises a ValueError when the substring is not found.

Parameters:
substr

Substring being searched.

startint

Left edge index.

endint

Right edge index.

Returns:
Series or Index of object

Examples

>>> import cudf
>>> s = cudf.Series(['abc', 'a','b' ,'ddb'])
>>> s.str.rindex('b')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: substring not found

Parameters such as start and end can also be used.

>>> s = cudf.Series(['abc', 'abb','ab' ,'ddb'])
>>> s.str.rindex('b', start=1, end=5)
0    1
1    2
2    1
3    2
dtype: int32