pyspark.sql.functions.csc#
- pyspark.sql.functions.csc(col)[source]#
Computes cosecant 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:
Columncosecant of the angle. Returns a column that evaluates to a double.
See also
Examples
Example 1: Compute the cosecant
>>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (PI() / 2), (PI() / 4) AS TAB(value)" ... ).select("*", sf.csc("value")).show() +------------------+------------------+ | value| CSC(value)| +------------------+------------------+ |1.5707963267948...| 1.0| |0.7853981633974...|1.4142135623730...| +------------------+------------------+
Example 2: Compute the cosecant 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.csc("value")).show() +-----+----------+ |value|CSC(value)| +-----+----------+ | 0.0| Infinity| | NaN| NaN| | NULL| NULL| +-----+----------+