milliseconds
Description
Extract the milliseconds from a Duration type.
Usage
<Expr>$dt$total_milliseconds()
Value
Expr of i64
Examples
library("polars")
df = pl$DataFrame(date = pl$datetime_range(
start = as.POSIXct("2020-1-1", tz = "GMT"),
end = as.POSIXct("2020-1-1 00:00:01", tz = "GMT"),
interval = "1ms"
))
df$select(
pl$col("date"),
diff_millisec = pl$col("date")$diff()$dt$total_milliseconds()
)
#> shape: (1_001, 2)
#> ┌─────────────────────────────┬───────────────┐
#> │ date ┆ diff_millisec │
#> │ --- ┆ --- │
#> │ datetime[ms, GMT] ┆ i64 │
#> ╞═════════════════════════════╪═══════════════╡
#> │ 2020-01-01 00:00:00 GMT ┆ null │
#> │ 2020-01-01 00:00:00.001 GMT ┆ 1 │
#> │ 2020-01-01 00:00:00.002 GMT ┆ 1 │
#> │ 2020-01-01 00:00:00.003 GMT ┆ 1 │
#> │ 2020-01-01 00:00:00.004 GMT ┆ 1 │
#> │ … ┆ … │
#> │ 2020-01-01 00:00:00.996 GMT ┆ 1 │
#> │ 2020-01-01 00:00:00.997 GMT ┆ 1 │
#> │ 2020-01-01 00:00:00.998 GMT ┆ 1 │
#> │ 2020-01-01 00:00:00.999 GMT ┆ 1 │
#> │ 2020-01-01 00:00:01 GMT ┆ 1 │
#> └─────────────────────────────┴───────────────┘