pyspark.sql.functions.exists¶
- 
pyspark.sql.functions.exists(col, f)[source]¶
- Returns whether a predicate holds for one or more elements in the array. - New in version 3.1.0. - Parameters
- colColumnor str
- name of column or expression 
- ffunction
- (x: Column) -> Column: ...returning the Boolean expression. Can use methods of- Column, functions defined in- pyspark.sql.functionsand Scala- UserDefinedFunctions. Python- UserDefinedFunctionsare not supported (SPARK-27052).
- :return: a :class:`~pyspark.sql.Column`
 
- col
 - Examples - >>> df = spark.createDataFrame([(1, [1, 2, 3, 4]), (2, [3, -1, 0])],("key", "values")) >>> df.select(exists("values", lambda x: x < 0).alias("any_negative")).show() +------------+ |any_negative| +------------+ | false| | true| +------------+