pyspark.sql.functions.cot#
- pyspark.sql.functions.cot(col)[source]#
Computes cotangent of the input column.
Added in version 3.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters:
- col
Columnor column name angle in radians. A column that evaluates to a double.
- col
- Returns:
Columncotangent of the angle. Returns a column that evaluates to a double.
See also
Examples
Example 1: Compute the cotangent
>>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (PI() / 4), (PI() / 16) AS TAB(value)" ... ).select("*", sf.cot("value")).show() +-------------------+------------------+ | value| COT(value)| +-------------------+------------------+ | 0.7853981633974...|1.0000000000000...| |0.19634954084936...| 5.027339492125...| +-------------------+------------------+
Example 2: Compute the cotangent of invalid values
>>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (0.0), (FLOAT('NAN')), (NULL) AS TAB(value)" ... ).select("*", sf.cot("value")).show() +-----+----------+ |value|COT(value)| +-----+----------+ | 0.0| Infinity| | NaN| NaN| | NULL| NULL| +-----+----------+