Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Locate the position of the first occurrence of substr in a string column, after position pos.
For the corresponding Databricks SQL function, see locate function.
Syntax
from pyspark.sql import functions as dbf
dbf.locate(substr=<substr>, str=<str>, pos=<pos>)
Parameters
| Parameter | Type | Description |
|---|---|---|
substr |
literal string |
a string |
str |
pyspark.sql.Column or str |
a Column of pyspark.sql.types.StringType |
pos |
int, optional |
start position (zero based) |
Returns
pyspark.sql.Column: position of the substring.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([('abcd',)], ['s',])
df.select('*', dbf.locate('b', 's', 1)).show()
df.select('*', dbf.locate('b', df.s, 3)).show()