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.
Returns the index (1-based) of the given string (str) in the comma-delimited list (strArray). Returns 0, if the string was not found or if the given string (str) contains a comma.
For the corresponding Databricks SQL function, see find_in_set function.
Syntax
from pyspark.sql import functions as dbf
dbf.find_in_set(str=<str>, str_array=<str_array>)
Parameters
| Parameter | Type | Description |
|---|---|---|
str |
pyspark.sql.Column or str |
The given string to be found. |
str_array |
pyspark.sql.Column or str |
The comma-delimited list. Examples -------- >>> df = spark.createDataFrame([("ab", "abc,b,ab,c,def")], ['a', 'b']) >>> df.select(find_in_set(df.a, df.b).alias('r')).collect() [Row(r=3)] |
Examples
df = spark.createDataFrame([("ab", "abc,b,ab,c,def")], ['a', 'b'])
df.select(find_in_set(df.a, df.b).alias('r')).collect()