Extract the hours from a Duration type
Description
Extract the hours from a Duration type
Usage
<Expr>$dt$total_hours(..., fractional = FALSE)
Arguments
…
|
These dots are for future extensions and must be empty. |
fractional
|
A bool to indicate whether to include the fractional component of the day. |
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_hours = pl$col("date")$diff()$dt$total_hours()
)
#> shape: (4, 2)
#> ┌────────────┬────────────┐
#> │ date ┆ diff_hours │
#> │ --- ┆ --- │
#> │ date ┆ i64 │
#> ╞════════════╪════════════╡
#> │ 2020-01-01 ┆ null │
#> │ 2020-01-02 ┆ 24 │
#> │ 2020-01-03 ┆ 24 │
#> │ 2020-01-04 ┆ 24 │
#> └────────────┴────────────┘