pyspark.sql.functions.atanh#

pyspark.sql.functions.atanh(col)[source]#

Computes inverse hyperbolic tangent of the input column.

New in version 3.1.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

target column to compute on.

Returns
Column

the column for computed results.

Examples

Example 1: Compute the inverse hyperbolic tangent

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame([(-0.5,), (0.0,), (0.5,)], ["value"])
>>> df.select("*", sf.atanh(df.value)).show()
+-----+-------------------+
|value|       ATANH(value)|
+-----+-------------------+
| -0.5|-0.5493061443340...|
|  0.0|                0.0|
|  0.5| 0.5493061443340...|
+-----+-------------------+

Example 2: Compute the inverse hyperbolic tangent of invalid values

>>> from pyspark.sql import functions as sf
>>> spark.sql(
...     "SELECT * FROM VALUES (-2), (2), (FLOAT('NAN')), (NULL) AS TAB(value)"
... ).select("*", sf.atanh("value")).show()
+-----+------------+
|value|ATANH(value)|
+-----+------------+
| -2.0|         NaN|
|  2.0|         NaN|
|  NaN|         NaN|
| NULL|        NULL|
+-----+------------+