I have the following data frame:
+----+----+----+----+
|col0|col1|col2|col3|
+----+----+----+----+
| 1| 21| 3|null|
| 4| 5| 23|null|
|null| 4| 5| 6|
|null| 9| 22| 42|
+----+----+----+----+
I tried computing the minimum of the column 'col1' and 1.5:
import pyspark.sql.functions as F
cond = df['col2'] > 10
df = df.withColumn('new_col', F.when(cond, F.least(F.col('col1')*0.2, 1.5)).otherwise(F.lit(100)))
df.show()
But I got the following exception:
TypeError: Invalid argument, not a string or column: 1.5 of type <class 'float'>. For column literals, use 'lit', 'array', 'struct' or 'create_map' function.