Extract milliseconds from underlying Datetime representation
Description
Applies to Datetime columns.
Usage
<Expr>$dt$millisecond()
Value
Expr of data type Int32
Examples
library("polars")
df = pl$DataFrame(
datetime = as.POSIXct(
c(
"1978-01-01 01:01:01",
"2024-10-13 05:30:14.500",
"2065-01-01 10:20:30.06"
),
"UTC"
)
)
df$with_columns(
millisecond = pl$col("datetime")$dt$millisecond()
)
#> shape: (3, 2)
#> ┌─────────────────────────────┬─────────────┐
#> │ datetime ┆ millisecond │
#> │ --- ┆ --- │
#> │ datetime[ms, UTC] ┆ i32 │
#> ╞═════════════════════════════╪═════════════╡
#> │ 1978-01-01 01:01:01 UTC ┆ 0 │
#> │ 2024-10-13 05:30:14.500 UTC ┆ 500 │
#> │ 2065-01-01 10:20:30.060 UTC ┆ 60 │
#> └─────────────────────────────┴─────────────┘