Skip to content

Commit dc47e92

Browse files
authored
fix: Include Array in to_physical (#19474)
1 parent f103fa8 commit dc47e92

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

crates/polars-core/src/series/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ impl Series {
600600
/// * Time -> Int64
601601
/// * Categorical -> UInt32
602602
/// * List(inner) -> List(physical of inner)
603+
/// * Array(inner) -> Array(physical of inner)
603604
/// * Struct -> Struct with physical repr of each struct column
604605
pub fn to_physical_repr(&self) -> Cow<Series> {
605606
use DataType::*;
@@ -620,6 +621,11 @@ impl Series {
620621
Cow::Owned(ca.physical().clone().into_series())
621622
},
622623
List(inner) => Cow::Owned(self.cast(&List(Box::new(inner.to_physical()))).unwrap()),
624+
#[cfg(feature = "dtype-array")]
625+
Array(inner, size) => Cow::Owned(
626+
self.cast(&Array(Box::new(inner.to_physical()), *size))
627+
.unwrap(),
628+
),
623629
#[cfg(feature = "dtype-struct")]
624630
Struct(_) => {
625631
let arr = self.struct_().unwrap();

py-polars/polars/expr/expr.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,16 @@ def to_physical(self) -> Expr:
407407
- :func:`polars.datatypes.Duration` -> :func:`polars.datatypes.Int64`
408408
- :func:`polars.datatypes.Categorical` -> :func:`polars.datatypes.UInt32`
409409
- `List(inner)` -> `List(physical of inner)`
410+
- `Array(inner)` -> `Struct(physical of inner)`
411+
- `Struct(fields)` -> `Array(physical of fields)`
410412
411413
Other data types will be left unchanged.
412414
415+
Warning
416+
-------
417+
The physical representations are an implementation detail
418+
and not guaranteed to be stable.
419+
413420
Examples
414421
--------
415422
Replicating the pandas

py-polars/polars/series/series.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4047,8 +4047,15 @@ def to_physical(self) -> Series:
40474047
- :func:`polars.datatypes.Duration` -> :func:`polars.datatypes.Int64`
40484048
- :func:`polars.datatypes.Categorical` -> :func:`polars.datatypes.UInt32`
40494049
- `List(inner)` -> `List(physical of inner)`
4050+
- `Array(inner)` -> `Array(physical of inner)`
4051+
- `Struct(fields)` -> `Struct(physical of fields)`
40504052
- Other data types will be left unchanged.
40514053
4054+
Warning
4055+
-------
4056+
The physical representations are an implementation detail
4057+
and not guaranteed to be stable.
4058+
40524059
Examples
40534060
--------
40544061
Replicating the pandas

0 commit comments

Comments
 (0)