polars.Expr.cos#
- Expr.cos() Expr[source]#
Compute the element-wise value for the cosine.
- Returns:
- Expr
Expression of data type
Float64.
Notes
The argument must be in radians. To convert from degrees to radians, call
.radians().Examples
>>> from math import pi >>> df = pl.DataFrame({"a": [0.0, pi / 2]}) >>> df.select(pl.col("a").cos()) shape: (2, 1) ┌────────────┐ │ a │ │ --- │ │ f64 │ ╞════════════╡ │ 1.0 │ │ 6.1232e-17 │ └────────────┘ >>> df = pl.DataFrame({"a": [0.0, 90]}) >>> df.select(pl.col("a").radians().cos()) shape: (2, 1) ┌────────────┐ │ a │ │ --- │ │ f64 │ ╞════════════╡ │ 1.0 │ │ 6.1232e-17 │ └────────────┘