pyspark.sql.functions.signum#
- pyspark.sql.functions.signum(col)[source]#
Computes the signum of the given value.
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or column name target column to compute on.
- col
- Returns
Column
the column for computed results.
Examples
>>> import pyspark.sql.functions as sf >>> spark.range(1).select( ... sf.signum(sf.lit(-5)), ... sf.signum(sf.lit(6)), ... sf.signum(sf.lit(float('nan'))), ... sf.signum(sf.lit(None)) ... ).show() +----------+---------+-----------+------------+ |SIGNUM(-5)|SIGNUM(6)|SIGNUM(NaN)|SIGNUM(NULL)| +----------+---------+-----------+------------+ | -1.0| 1.0| NaN| NULL| +----------+---------+-----------+------------+