pandas.Series.str.find #
- 系列.str。find ( sub , start = 0 , end = None ) [来源] #
返回系列/索引中每个字符串的最低索引。
每个返回的索引对应于子字符串完全包含在[start:end]之间的位置。失败时返回-1。相当于标准
str.find()
。- 参数:
- 子字符串
正在搜索的子字符串。
- 开始整数
左边缘索引。
- 结束整数
右边缘索引。
- 返回:
- int 的系列或索引。
也可以看看
rfind
返回每个字符串中的最高索引。
例子
对于 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