pyspark.sql.functions.atan2#

pyspark.sql.functions.atan2(col1, col2)[source]#

Compute the angle in radians between the positive x-axis of a plane and the point given by the coordinates

Added in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:
col1Column, column name or float

coordinate on y-axis. A column that evaluates to a double.

col2Column, column name or float

coordinate on x-axis. A column that evaluates to a double.

Returns:
Column

the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates, as if computed by java.lang.Math.atan2() Returns a column that evaluates to a double.

Examples

>>> from pyspark.sql import functions as sf
>>> spark.range(1).select(sf.atan2(sf.lit(1), sf.lit(2))).show()
+------------------+
|       ATAN2(1, 2)|
+------------------+
|0.4636476090008...|
+------------------+