pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.21k stars 1.95k forks source link

Using `pl.Expr.struct.field` within `pl.Expr.list.eval` produces ColumnNotFoundError #19458

Closed hericks closed 1 week ago

hericks commented 1 week ago

Checks

Reproducible example

import polars as pl

df = pl.DataFrame({
    "x": [[{"x": 1}]]
})

df.with_columns(
    pl.col("x").list.eval(pl.struct(pl.element().struct.field("x")))
)
# ColumnNotFoundError: 

Log output

No response

Issue description

It is not possible to select a specific field of each element in a list of struct using pl.Expr.list.eval.

Expected behavior

No ColumnNotFoundError. Instead a dataframe with a single column x having value 1 in the only row.

Installed versions

``` --------Version info--------- Polars: 1.11.0 Index type: UInt32 Platform: macOS-14.6.1-arm64-arm-64bit Python: 3.12.4 (main, Sep 28 2024, 16:28:05) [Clang 15.0.0 (clang-1500.3.9.4)] LTS CPU: False ----Optional dependencies---- adbc_driver_manager altair cloudpickle connectorx deltalake fastexcel fsspec gevent great_tables 0.13.0 matplotlib 3.9.2 nest_asyncio 1.6.0 numpy 2.0.1 openpyxl pandas 2.2.2 pyarrow 17.0.0 pydantic pyiceberg sqlalchemy torch xlsx2csv xlsxwriter ```
cmdlineluser commented 1 week ago

This is fixed on main https://github.com/pola-rs/polars/issues/19345