pyspark.sql.functions.array_max

pyspark.sql.functions.array_max(col: ColumnOrName) → pyspark.sql.column.Column[source]

Collection function: returns the maximum value of the array.

New in version 2.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

name of column or expression

Returns
Column

maximum value of an array.

Examples

>>> df = spark.createDataFrame([([2, 1, 3],), ([None, 10, -1],)], ['data'])
>>> df.select(array_max(df.data).alias('max')).collect()
[Row(max=3), Row(max=10)]