Nóta
Aðgangur að þessari síðu krefst heimildar. Þú getur prófað aðskrá þig inn eða breyta skráasöfnum.
Aðgangur að þessari síðu krefst heimildar. Þú getur prófað að breyta skráasöfnum.
Computes hyperbolic tangent of the input column. Supports Spark Connect.
For the corresponding Databricks SQL function, see tanh function.
Syntax
from pyspark.sql import functions as dbf
dbf.tanh(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
hyperbolic angle |
Returns
pyspark.sql.Column: hyperbolic tangent of the given value as if computed by java.lang.Math.tanh()
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([(-1,), (0,), (1,)], ["value"])
df.select("*", dbf.tanh(df.value)).show()
+-----+-------------------+
|value| TANH(value)|
+-----+-------------------+
| -1|-0.7615941559557...|
| 0| 0.0|
| 1| 0.7615941559557...|
+-----+-------------------+
from pyspark.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)"
).select("*", dbf.tanh("value")).show()
+-----+-----------+
|value|TANH(value)|
+-----+-----------+
| NaN| NaN|
| NULL| NULL|
+-----+-----------+