pandas.Series.str.rfind#

Series.str.rfind(sub, start=0, end=None)[源代码]#

返回 Series/Index 中每个字符串的最高索引。

返回的每个索引对应于子字符串完全包含在 [start:end] 之间的位置。失败时返回 -1。等效于标准的 str.rfind()

Parameters:
substr

要搜索的子字符串。

startint

左边缘索引。

endint

右边缘索引。

Returns:
int 类型的 Series 或 Index。

参见

find

返回每个字符串的最低索引。

Examples

对于 Series.str.find:

>>> ser = pd.Series(["cow_", "duck_", "do_ve"])
>>> ser.str.find("_")
0   3
1   4
2   2
dtype: int64

对于 Series.str.rfind:

>>> ser = pd.Series(["_cow_", "duck_", "do_v_e"])
>>> ser.str.rfind("_")
0   4
1   4
2   4
dtype: int64