pyspark.sql.functions.csc#

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

Computes cosecant of the input column.

New in version 3.3.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

angle in radians.

Returns
Column

cosecant of the angle.

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|
+-----+----------+