Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Computes the signum of the given value. Supports Spark Connect.
For the corresponding Databricks SQL function, see signum function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.signum(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
target column to compute on. |
Returns
pyspark.sql.Column: the column for computed results.
Examples
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(
dbf.signum(dbf.lit(-5)),
dbf.signum(dbf.lit(6)),
dbf.signum(dbf.lit(float('nan'))),
dbf.signum(dbf.lit(None))
).show()
+----------+---------+-----------+------------+
|SIGNUM(-5)|SIGNUM(6)|SIGNUM(NaN)|SIGNUM(NULL)|
+----------+---------+-----------+------------+
| -1.0| 1.0| NaN| NULL|
+----------+---------+-----------+------------+