Open avhz opened 6 months ago
Can you please show an example of the code you would like to be able to write?
For example, something like the example in the Polars docs here:
use chrono::prelude::*;
let date = polars::time::date_range(
"date",
NaiveDate::from_ymd_opt(2022, 1, 1)
.unwrap()
.and_hms_opt(0, 0, 0)
.unwrap(),
NaiveDate::from_ymd_opt(2022, 1, 5)
.unwrap()
.and_hms_opt(0, 0, 0)
.unwrap(),
Duration::parse("1d"),
ClosedWindow::Both,
TimeUnit::Milliseconds,
None,
)?
.cast(&DataType::Date)?;
let datetime = polars::time::date_range(
"datetime",
NaiveDate::from_ymd_opt(2022, 1, 1)
.unwrap()
.and_hms_opt(0, 0, 0)
.unwrap(),
NaiveDate::from_ymd_opt(2022, 1, 5)
.unwrap()
.and_hms_opt(0, 0, 0)
.unwrap(),
Duration::parse("1d"),
ClosedWindow::Both,
TimeUnit::Milliseconds,
None,
)?;
let df = df! (
"date" => date,
"datetime" => datetime,
)?;
But replace chrono's NaiveDate
with time's PrimitiveDatetime
, for example.
Any thoughts on this ?
To be more precise, I would like to do something like:
use time::macros::{date, datetime};
let df: DataFrame = df!(
"date" => &[
date!(2020-01-01),
date!(2021-01-01),
date!(2022-01-01)
],
"datetime" => &[
datetime!(2020-01-01 0:00),
datetime!(2021-01-01 0:00),
datetime!(2022-01-01 0:00)
],
)
.unwrap();
println!("{}", df);
Description
I would like to be able to create date columns from the time-rs crate (in addition to the currently supported chrono input).
Is this something that would be possible? I could also try to do it myself if no one is keen enough to do it.