尽管:
成功安装
cargo add polars-lazy
以下代码会导致错误:
错误[E0433]:无法解析:
legacy
找不到arrow
错误[E0433]:无法解析:使用未声明的包或模块
polars_core
PolarsResult
错误[E0412]:在此范围内找不到类型DataFrame
错误[E0412]:在此范围内找不到类型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() }
注意:Cargo.toml
[dependencies]
arrow = "53.2.0"
polars-lazy = "0.44.2"