pyspark.sql.functions.bool_and#

pyspark.sql.functions.bool_and(col)[source]#

Aggregate function: returns true if all values of col are true.

New in version 3.5.0.

Parameters
colColumn or str

column to check if all values are true.

Returns
Column

true if all values of col are true, false otherwise.

Examples

>>> df = spark.createDataFrame([[True], [True], [True]], ["flag"])
>>> df.select(bool_and("flag")).show()
+--------------+
|bool_and(flag)|
+--------------+
|          true|
+--------------+
>>> df = spark.createDataFrame([[True], [False], [True]], ["flag"])
>>> df.select(bool_and("flag")).show()
+--------------+
|bool_and(flag)|
+--------------+
|         false|
+--------------+
>>> df = spark.createDataFrame([[False], [False], [False]], ["flag"])
>>> df.select(bool_and("flag")).show()
+--------------+
|bool_and(flag)|
+--------------+
|         false|
+--------------+