polars_core/frame/
from.rs1use crate::prelude::*;
2
3impl TryFrom<StructArray> for DataFrame {
4 type Error = PolarsError;
5
6 fn try_from(arr: StructArray) -> PolarsResult<Self> {
7 let (fld, _length, arrs, nulls) = arr.into_data();
8 polars_ensure!(
9 nulls.is_none(),
10 ComputeError: "cannot deserialize struct with nulls into a DataFrame"
11 );
12 let columns = fld
13 .iter()
14 .zip(arrs)
15 .map(|(fld, arr)| {
16 unsafe {
19 Series::_try_from_arrow_unchecked_with_md(
20 fld.name.clone(),
21 vec![arr],
22 fld.dtype(),
23 fld.metadata.as_deref(),
24 )
25 }
26 .map(Column::from)
27 })
28 .collect::<PolarsResult<Vec<_>>>()?;
29 DataFrame::new(columns)
30 }
31}