pyspark.sql.functions.negative

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

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|
+------------+