pyspark.sql.functions.negative#
- pyspark.sql.functions.negative(col)[source]#
Returns the negative value.
New in version 3.5.0.
- Parameters
- col
Column
or column name column to calculate negative value for.
- col
- Returns
Column
negative value.
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| +-----+---------------+