polars.arctan2d#
- polars.arctan2d(y: str | Expr, x: str | Expr) Expr [source]#
Compute two argument arctan in degrees.
Returns the angle (in degrees) in the plane between the positive x-axis and the ray from the origin to (x,y).
- Parameters:
- y
Column name or Expression.
- x
Column name or Expression.
Examples
>>> import math >>> twoRootTwo = math.sqrt(2) / 2 >>> df = pl.DataFrame( ... { ... "y": [twoRootTwo, -twoRootTwo, twoRootTwo, -twoRootTwo], ... "x": [twoRootTwo, twoRootTwo, -twoRootTwo, -twoRootTwo], ... } ... ) >>> df.select( ... pl.arctan2d("y", "x").alias("atan2d"), pl.arctan2("y", "x").alias("atan2") ... ) shape: (4, 2) ┌────────┬───────────┐ │ atan2d ┆ atan2 │ │ --- ┆ --- │ │ f64 ┆ f64 │ ╞════════╪═══════════╡ │ 45.0 ┆ 0.785398 │ │ -45.0 ┆ -0.785398 │ │ 135.0 ┆ 2.356194 │ │ -135.0 ┆ -2.356194 │ └────────┴───────────┘