pola-rs / polars

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

DataFrame.__pow__ fails for (series, column) inputs #17787

Open mcrumiller opened 1 month ago

mcrumiller commented 1 month ago

Issue Description

When pow() is used in a select, if the first argument is an external Series and the second is a column, an invalid ColumnNotFoundError is raised.

Noticed as a result of looking into #17760.

import polars as pl

df = pl.DataFrame({"a": [1, 1, 2]})
s = pl.Series("b", [1, 1, 1])
df.select(s ** pl.col("a"))
polars.exceptions.ColumnNotFoundError: a

Installed versions

main

mcrumiller commented 1 month ago

The real error is in Series * expr failing if expr is a column:

pl.Series() * pl.col("a")   # <Expr ['[(Series) * (col("a"))]'] at 0x7F19A0B5CE60>
pl.Series() ** pl.col("a")  # polars.exceptions.ColumnNotFoundError: a