diff --git a/crates/polars-core/src/series/mod.rs b/crates/polars-core/src/series/mod.rs index 9508a72cc1d7..38cb14f3a0c8 100644 --- a/crates/polars-core/src/series/mod.rs +++ b/crates/polars-core/src/series/mod.rs @@ -600,6 +600,7 @@ impl Series { /// * Time -> Int64 /// * Categorical -> UInt32 /// * List(inner) -> List(physical of inner) + /// * Array(inner) -> Array(physical of inner) /// * Struct -> Struct with physical repr of each struct column pub fn to_physical_repr(&self) -> Cow { use DataType::*; @@ -620,6 +621,11 @@ impl Series { Cow::Owned(ca.physical().clone().into_series()) }, List(inner) => Cow::Owned(self.cast(&List(Box::new(inner.to_physical()))).unwrap()), + #[cfg(feature = "dtype-array")] + Array(inner, size) => Cow::Owned( + self.cast(&Array(Box::new(inner.to_physical()), *size)) + .unwrap(), + ), #[cfg(feature = "dtype-struct")] Struct(_) => { let arr = self.struct_().unwrap(); diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index 514c9205398b..4613aabd4beb 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -407,9 +407,16 @@ def to_physical(self) -> Expr: - :func:`polars.datatypes.Duration` -> :func:`polars.datatypes.Int64` - :func:`polars.datatypes.Categorical` -> :func:`polars.datatypes.UInt32` - `List(inner)` -> `List(physical of inner)` + - `Array(inner)` -> `Struct(physical of inner)` + - `Struct(fields)` -> `Array(physical of fields)` Other data types will be left unchanged. + Warning + ------- + The physical representations are an implementation detail + and not guaranteed to be stable. + Examples -------- Replicating the pandas diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index ea37a64aa778..8e27b3470b16 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -4047,8 +4047,15 @@ def to_physical(self) -> Series: - :func:`polars.datatypes.Duration` -> :func:`polars.datatypes.Int64` - :func:`polars.datatypes.Categorical` -> :func:`polars.datatypes.UInt32` - `List(inner)` -> `List(physical of inner)` + - `Array(inner)` -> `Array(physical of inner)` + - `Struct(fields)` -> `Struct(physical of fields)` - Other data types will be left unchanged. + Warning + ------- + The physical representations are an implementation detail + and not guaranteed to be stable. + Examples -------- Replicating the pandas