pyspark.sql.functions.
signum
Computes the signum of the given value.
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
target column to compute on.
the column for computed results.
Examples
>>> df = spark.range(1) >>> df.select(signum(lit(-5))).show() +----------+ |SIGNUM(-5)| +----------+ | -1.0| +----------+
>>> df.select(signum(lit(6))).show() +---------+ |SIGNUM(6)| +---------+ | 1.0| +---------+