expm1
Computes the exponential of the given value minus one. Supports Spark Connect.
For the corresponding Databricks SQL function, see expm1 function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.expm1(col=<col>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| column to calculate exponential for. |
Returns
pyspark.sql.Column: exponential less one.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.sql("SELECT id AS value FROM RANGE(5)")
df.select("*", dbf.expm1(df.value)).show()
Output
+-----+------------------+
|value| EXPM1(value)|
+-----+------------------+
| 0| 0.0|
| 1| 1.718281828459...|
| 2| 6.38905609893...|
| 3|19.085536923187...|
| 4|53.598150033144...|
+-----+------------------+
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)"
).select("*", dbf.expm1("value")).show()
Output
+-----+------------+
|value|EXPM1(value)|
+-----+------------+
| NaN| NaN|
| NULL| NULL|
+-----+------------+