Σημείωμα
Η πρόσβαση σε αυτήν τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να εισέλθετε ή να αλλάξετε καταλόγους.
Η πρόσβαση σε αυτήν τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να αλλάξετε καταλόγους.
Computes the signum of the given value. Supports Spark Connect.
For the corresponding Databricks SQL function, see signum function.
Syntax
from pyspark.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.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|
+----------+---------+-----------+------------+