当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python cudf.core.column.string.StringMethods.rindex用法及代码示例


用法:

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

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

参数

substr

正在搜索的子字符串。

startint

左边索引。

endint

右边索引。

返回

对象的系列或索引

例子

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

相关用法


注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.core.column.string.StringMethods.rindex。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。