pandas.Series.str.index
- Series.str.index(sub, start=0, end=None)[source]
-
Возвращает самые низкие индексы в каждой строке в Series/Index.
Каждый из возвращённых индексов соответствует позиции, где подстрока полностью содержится между [start:end]. Это то же самое, что
str.find, за исключением того, что вместо возвращения -1, генерируется исключение ValueError, когда подстрока не найдена. Эквивалентно стандартномуstr.index.- Параметры:
-
- sub:str
-
Искомая подстрока.
- start:int
-
Индекс левой границы.
- end:int
-
Индекс правой границы.
- Возвращаемое значение:
-
- Series или Index объекта
См. также
rindex-
Возвращает самые высокие индексы в каждой строке.
Примеры
Для Series.str.index:
>>> ser = pd.Series(["horse", "eagle", "donkey"]) >>> ser.str.index("e") 0 4 1 0 2 4 dtype: int64Для Series.str.rindex:
>>> ser = pd.Series(["Deer", "eagle", "Sheep"]) >>> ser.str.rindex("e") 0 2 1 4 2 3 dtype: int64
© 2008–2022, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.2.2/reference/api/pandas.Series.str.index.html