pyspark.sql.functions.array_contains¶
-
pyspark.sql.functions.
array_contains
(col, value)[source]¶ Collection function: returns null if the array is null, true if the array contains the given value, and false otherwise.
New in version 1.5.0.
- Parameters
- col
Column
or str name of column containing array
- value :
value or column to check for in array
- col
Examples
>>> df = spark.createDataFrame([(["a", "b", "c"],), ([],)], ['data']) >>> df.select(array_contains(df.data, "a")).collect() [Row(array_contains(data, a)=True), Row(array_contains(data, a)=False)] >>> df.select(array_contains(df.data, lit("a"))).collect() [Row(array_contains(data, a)=True), Row(array_contains(data, a)=False)]