pyspark.sql.functions.least#

pyspark.sql.functions.least(*cols)[source]#

Returns the least value of the list of column names, skipping null values. This function takes at least 2 parameters. It will return null if all parameters are null.

Added in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:
colsColumn or column name

column names or columns to be compared Each a column of any orderable type.

Returns:
Column

least value. Returns a column of the same type as the input.

Examples

>>> import pyspark.sql.functions as sf
>>> df = spark.createDataFrame([(1, 4, 3)], ['a', 'b', 'c'])
>>> df.select("*", sf.least(df.a, "b", df.c)).show()
+---+---+---+--------------+
|  a|  b|  c|least(a, b, c)|
+---+---+---+--------------+
|  1|  4|  3|             1|
+---+---+---+--------------+