How can I calculate the duration using polars::LazyFrame and the Datatype::Datetime?

26 Views Asked by At

I'm currently working on developing tools to manipulate data for my personal use. While attempting to process a very large dataset, I encountered an error indicating that the trait 'AsRef<[Expr]>' is not implemented for 'Expr'.

    let data:LazyFrame = read_data(name)
        .unwrap()
        .with_column(col("updatedAt").cast(DataType::Datetime(TimeUnit::Milliseconds, None)))
        .with_column(col("createdAt").cast(DataType::Datetime(TimeUnit::Milliseconds, None)))
        .with_columns(col("updatedAt").sub(col("createdAt")).dt().total_seconds()); // This particular line of code generates an error.
    let data2 = data.collect().unwrap();  
0

There are 0 best solutions below