Skip to main content

atan2

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

For the corresponding Databricks SQL function, see atan2 function.

Syntax​

Python
from pyspark.sql import functions as dbf

dbf.atan2(col1=<col1>, col2=<col2>)

Parameters​

Parameter

Type

Description

col1

pyspark.sql.Column, column name or float

coordinate on y-axis

col2

pyspark.sql.Column, column name or float

coordinate on x-axis

Parameter

Type

Description

col1

pyspark.sql.Column, column name or float

coordinate on y-axis

col2

pyspark.sql.Column, column name or float

coordinate on x-axis

Returns​

pyspark.sql.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()

Examples​

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