pyspark.sql.functions.negate#

pyspark.sql.functions.negate(col)#

Returns the negative value.

New in version 3.5.0.

Parameters
colColumn or str

column to calculate negative value for.

Returns
Column

negative value.

Examples

>>> import pyspark.sql.functions as sf
>>> spark.range(3).select(sf.negative("id")).show()
+------------+
|negative(id)|
+------------+
|           0|
|          -1|
|          -2|
+------------+