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

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

返回每个字符串中子字符串完全包含在[start:end]之间的最高索引。这与str.rfind相同,不同之处在于当未找到子字符串时,它会引发ValueError而不是返回-1。

Parameters:
substr

正在搜索的子字符串。

startint

左侧边缘索引。

endint

右侧边缘索引。

Returns:
Series or Index of object

示例

>>> 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

诸如startend等参数也可以使用。

>>> 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