Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-core/src/utils/schema.rs
6940 views
1
use polars_utils::format_pl_smallstr;
2
3
use crate::prelude::*;
4
5
/// Convert a collection of [`DataType`] into a schema.
6
///
7
/// Field names are set as `column_0`, `column_1`, and so on.
8
///
9
/// [`DataType`]: crate::datatypes::DataType
10
pub fn dtypes_to_schema<I>(dtypes: I) -> Schema
11
where
12
I: IntoIterator<Item = DataType>,
13
{
14
dtypes
15
.into_iter()
16
.enumerate()
17
.map(|(i, dtype)| Field::new(format_pl_smallstr!("column_{i}"), dtype))
18
.collect()
19
}
20
21