pyspark.sql.functions.asinh#

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

Computes inverse hyperbolic sine 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 sine

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

Example 2: Compute the inverse hyperbolic sine of invalid values

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