Despite the:
reading of the polar_lazy 0.44.2
sucessful installation of cargo add polars-lazy
the following code results in errors:
error[E0433]: failed to resolve: could not find legacy
in arrow
error[E0433]: failed to resolve: use of undeclared crate or module polars_core
error[E0412]: cannot find type PolarsResult
in this scope
error[E0412]: cannot find type DataFrame
in this scope
use polars_core::prelude::*;
use polars_core::df;
use polars_lazy::prelude::*;
use arrow::legacy::prelude::QuantileMethod;
fn main() {
let test = example()
println!("show dataframe: {:?}", test);
}
fn example() -> PolarsResult<DataFrame> {
let df = df!(
"date" => ["2020-08-21", "2020-08-21", "2020-08-22", "2020-08-23", "2020-08-22"],
"temp" => [20, 10, 7, 9, 1],
"rain" => [0.2, 0.1, 0.3, 0.1, 0.01]
)?;
df.lazy()
.group_by([col("date")])
.agg([
col("rain").min().alias("min_rain"),
col("rain").sum().alias("sum_rain"),
col("rain").quantile(lit(0.5), QuantileMethod::Nearest).alias("median_rain"),
])
.sort(["date"], Default::default())
.collect()
}
N.B: Cargo.toml
[dependencies]
arrow = "53.2.0"
polars-lazy = "0.44.2"
It's a little hard to tell, but the "arrow
" crate used in the example is a renamed import of polars-arrow
, not the arrow
crate (see the dependencies in the Cargo.toml
):
[dependencies.arrow] default-features = false features = ["compute_aggregate", "compute_arithmetics", "compute_bitwise", "compute_boolean", "compute_boolean_kleene", "compute_cast", "compute_comparison"] package = "polars-arrow" version = "0.44.2"
And it feels a little like stating the obvious, but to use polars_core
you'll have to add polars-core
to your dependencies.
So you should remove arrow = "53.2.0"
from your dependencies and instead add:
polars-core = "0.44.2"
arrow = { version = "0.44.2", package = "polars-arrow" }