Series.str.find(sub, start=0, end=None)????????,????
Series.str.rfind(sub, start=0, end=None)????????,????Series.str.index(sub, start=0, end=None)????????,????,???????
Series.str.rindex(sub, start=0, end=None)????????,????,???????
??:
sub : ???
start : ??,???
end : ??,???
??:
??Series/??Index
import pandas as pd
s = pd.Series(['A', 'B', 'C', 'Aaba', 'Baca', 'CABA', 'dog', 'cat'])
print(s.str.find("a"))
0 -1
1 -1
2 -1
3 1
4 1
5 -1
6 -1
7 1
dtype: int64
print(s.str.rfind("a"))
0 -1
1 -1
2 -1
3 3
4 3
5 -1
6 -1
7 1
dtype: int64
本文介绍了Pandas库中Series对象的字符串操作方法,包括find、rfind、index和rindex等方法的使用方式及参数说明,并通过实例展示了如何在Python中使用这些方法来查找特定子字符串的位置。

1万+

被折叠的 条评论
为什么被折叠?



