pyspark.sql.functions.cosh#
- pyspark.sql.functions.cosh(col)[source]#
Computes hyperbolic cosine of the input column.
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or column name hyperbolic angle
- col
- Returns
Column
hyperbolic cosine of the angle, as if computed by java.lang.Math.cosh()
Examples
Example 1: Compute the cosine
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([(-1,), (0,), (1,)], ["value"]) >>> df.select("*", sf.cosh(df.value)).show() +-----+-----------------+ |value| COSH(value)| +-----+-----------------+ | -1|1.543080634815...| | 0| 1.0| | 1|1.543080634815...| +-----+-----------------+
Example 2: Compute the cosine of invalid values
>>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)" ... ).select("*", sf.cosh("value")).show() +-----+-----------+ |value|COSH(value)| +-----+-----------+ | NaN| NaN| | NULL| NULL| +-----+-----------+