pyspark.sql.functions.negative#

pyspark.sql.functions.negative(col)[source]#

Returns the negative value.

Added in version 3.5.0.

Parameters:
colColumn or column name

column to calculate negative value for. A column that evaluates to a numeric or interval.

Returns:
Column

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

Examples

>>> import pyspark.sql.functions as sf
>>> df = spark.createDataFrame([(-1,), (0,), (1,)], ["value"])
>>> df.select("*", sf.negative(df.value)).show()
+-----+---------------+
|value|negative(value)|
+-----+---------------+
|   -1|              1|
|    0|              0|
|    1|             -1|
+-----+---------------+