Skip to content

Commit

Permalink
fix: Include Array in to_physical (#19474)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Oct 27, 2024
1 parent f103fa8 commit dc47e92
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/polars-core/src/series/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Series> {
use DataType::*;
Expand All @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc47e92

Please sign in to comment.