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
- col
Column
or column name column to check if all values are true.
- col
- Returns
Column
true if all values of col are true, false otherwise.
See also
Examples
>>> import pyspark.sql.functions as sf >>> df = spark.createDataFrame([[True], [True], [True]], ["flag"]) >>> df.select(sf.bool_and("flag")).show() +--------------+ |bool_and(flag)| +--------------+ | true| +--------------+
>>> import pyspark.sql.functions as sf >>> df = spark.createDataFrame([[True], [False], [True]], ["flag"]) >>> df.select(sf.bool_and("flag")).show() +--------------+ |bool_and(flag)| +--------------+ | false| +--------------+
>>> import pyspark.sql.functions as sf >>> df = spark.createDataFrame([[False], [False], [False]], ["flag"]) >>> df.select(sf.bool_and("flag")).show() +--------------+ |bool_and(flag)| +--------------+ | false| +--------------+