当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python pyspark Series.str.find用法及代码示例


本文简要介绍 pyspark.pandas.Series.str.find 的用法。

用法:

str.find(sub: str, start: int = 0, end: Optional[int] = None) → ps.Series

返回 Series 中每个字符串的最低索引,其中子字符串完全包含在 [start:end] 之间。

失败时返回-1。相当于标准 str.find()

参数

substr

正在搜索的子字符串。

startint

左边索引。

endint

右边索引。

返回

int系列

一系列最低匹配索引。

例子

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

相关用法


注:本文由纯净天空筛选整理自spark.apache.org大神的英文原创作品 pyspark.pandas.Series.str.find。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。