[dependencies]
polars = { version = "0.35.4", features = ["lazy", "fmt", "partition_by", "http", "streaming", "async", "aws", "json", "random"] }
polars-io = { version = "0.35.4", features = ["csv", "aws", "fmt", "http", "json"] }
+
+[build]
+rustflags = ["-C", "link-arg=-fuse-ld=lld"]
\ No newline at end of file
-// use polars::prelude_core::*;
-// use polars::prelude_io::*;
use polars::prelude::*;
use polars_io::csv::CsvReader;
fn main() {
+
+ // set some columns to be parsed as numeric
+ let mut schema_override = Schema::new();
+ let _ = schema_override.with_column("2022".into(),DataType::Float64);
+ let schema_override =
+ Some(Arc::new(schema_override));
+
+ // Some string values in numeric fields should be ignored
+ let null_values =
+ Some(NullValues::AllColumns(vec!("Reported".to_string(),"Estimated".to_string())));
+
+ // read and parse from disk
let df = CsvReader::from_path("data/bop.csv").unwrap()
.has_header(true)
+ .with_dtypes(schema_override)
+ .with_null_values(null_values)
.finish().unwrap();
+ // one country
+ let df = df.filter(&df.column("Country Name").unwrap().
+ equal("France").unwrap()).unwrap();
+
+ // values not status
+ let df = df.filter(&df.column("Attribute").unwrap().
+ equal("Value").unwrap()).unwrap();
+
+ // just a few columns
+ let df = df.select(["Country Name","Indicator Name","Indicator Code","2022"]).unwrap();
+
println!("df: {:?}",df);
-
}