pyspark.sql.functions.acosh#
- pyspark.sql.functions.acosh(col)[source]#
Mathematical Function: Computes the inverse hyperbolic cosine (also known as arcosh) of the given column or expression.
New in version 3.1.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str The target column or expression to compute the inverse hyperbolic cosine on.
- col
- Returns
Column
A new column object representing the inverse hyperbolic cosine of the input.
Examples
Example 1: Compute the inverse hyperbolic cosine of a column of numbers
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(1,), (2,)], ["value"]) >>> df.select("value", sf.acosh(df.value)).show() +-----+------------------+ |value| ACOSH(value)| +-----+------------------+ | 1| 0.0| | 2|1.3169578969248...| +-----+------------------+
Example 2: Compute the inverse hyperbolic cosine of a column with null values
>>> from pyspark.sql import functions as sf >>> from pyspark.sql.types import StructType, StructField, IntegerType >>> schema = StructType([StructField("value", IntegerType(), True)]) >>> df = spark.createDataFrame([(None,)], schema=schema) >>> df.select(sf.acosh(df.value)).show() +------------+ |ACOSH(value)| +------------+ | NULL| +------------+
Example 3: Compute the inverse hyperbolic cosine of a column with values less than 1
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(0.5,), (-0.5,)], ["value"]) >>> df.select(sf.acosh(df.value)).show() +------------+ |ACOSH(value)| +------------+ | NaN| | NaN| +------------+