pyspark.sql.functions.radians#

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

Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

New in version 2.1.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

angle in degrees

Returns
Column

angle in radians, as if computed by java.lang.Math.toRadians()

Examples

>>> from pyspark.sql import functions as sf
>>> spark.sql(
...     "SELECT * FROM VALUES (180), (90), (45), (0) AS TAB(value)"
... ).select("*", sf.radians("value")).show()
+-----+------------------+
|value|    RADIANS(value)|
+-----+------------------+
|  180| 3.141592653589...|
|   90|1.5707963267948...|
|   45|0.7853981633974...|
|    0|               0.0|
+-----+------------------+