I am trying to specify a Schema for polars::prelude::LazyCsvReader
, as follows:
use polars::prelude::*;
let myschema = Schema::new(
vec![
Field::new("sepal_length", DataType::Float64),
Field::new("sepal_width", DataType::Float64),
Field::new("petal_length", DataType::Utf8),
Field::new("petal_width", DataType::Float64),
Field::new("species", DataType::Utf8),
]
);
but I get the following error:
error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> src/main.rs:93:20
|
93 | let myschema = Schema::new(
| ^^^^^^^^^^^
94 | / vec![
95 | | Field::new("sepal_length", DataType::Float64),
96 | | Field::new("sepal_width", DataType::Float64),
97 | | Field::new("petal_length", DataType::Utf8),
98 | | Field::new("petal_width", DataType::Float64),
99 | | Field::new("species", DataType::Utf8),
100 | | ]
| |_________- argument of type `Vec<polars::prelude::Field>` unexpected
I understand that this is due to the fact that my compiler knows about polars_core::Schema
and not polars::prelude::Schema
.
- How can I ensure the correct struct method is used?
- This isn't the first time happening to me with Rust: is there a general rule on which one of the many functions/structs with the same name is used?
Thanks