pyspark.pandas.Series.str.rfind

str.rfind(sub: str, start: int = 0, end: Optional[int] = None) → pyspark.pandas.series.Series

Return highest indexes in each string in the Series where the substring is fully contained between [start:end].

Return -1 on failure. Equivalent to standard str.rfind().

Parameters
substr

Substring being searched.

startint

Left edge index.

endint

Right edge index.

Returns
Series of int

Series of highest matching indexes.

Examples

>>> s = ps.Series(['apple', 'oranges', 'bananas'])
>>> s.str.rfind('a')
0    0
1    2
2    5
dtype: int64
>>> s.str.rfind('a', start=2)
0   -1
1    2
2    5
dtype: int64
>>> s.str.rfind('a', end=1)
0    0
1   -1
2   -1
dtype: int64
>>> s.str.rfind('a', start=2, end=2)
0   -1
1   -1
2   -1
dtype: int64