polars_xdt.to_julian_date#
- polars_xdt.to_julian_date(expr: str | Expr) Expr #
Return the Julian date corresponding to given datetimes.
Examples
>>> from datetime import datetime >>> import polars_xdt as xdt >>> df = pl.DataFrame( ... { ... "date_col": [ ... datetime(2013, 1, 1, 0, 30), ... datetime(2024, 1, 7, 13, 18, 51), ... ], ... } ... ) >>> with pl.Config(float_precision=10) as cfg: ... df.with_columns(julian_date=xdt.to_julian_date("date_col")) shape: (2, 2) ┌─────────────────────┬────────────────────┐ │ date_col ┆ julian_date │ │ --- ┆ --- │ │ datetime[μs] ┆ f64 │ ╞═════════════════════╪════════════════════╡ │ 2013-01-01 00:30:00 ┆ 2456293.5208333335 │ │ 2024-01-07 13:18:51 ┆ 2460317.0547569445 │ └─────────────────────┴────────────────────┘