Skip to content

Extract the minutes from a Duration type

Description

Extract the minutes from a Duration type

Usage

<Expr>$dt$total_minutes()

Value

A polars expression

Examples

library("polars")

df <- pl$select(
  date = pl$date_range(
    start = as.Date("2020-1-1"),
    end = as.Date("2020-1-4"),
    interval = "1d"
  )
)
df$with_columns(
  diff_minutes = pl$col("date")$diff()$dt$total_minutes()
)
#> shape: (4, 2)
#> ┌────────────┬──────────────┐
#> │ date       ┆ diff_minutes │
#> │ ---        ┆ ---          │
#> │ date       ┆ i64          │
#> ╞════════════╪══════════════╡
#> │ 2020-01-01 ┆ null         │
#> │ 2020-01-02 ┆ 1440         │
#> │ 2020-01-03 ┆ 1440         │
#> │ 2020-01-04 ┆ 1440         │
#> └────────────┴──────────────┘