We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
struct
import polars as pl df = pl.LazyFrame({"x": [1, 2], "y": [4, 5]}) (df .with_columns( q1 = pl.struct(pl.col.x - pl.col.y.mean()), q2 = pl.struct(pl.col.x - pl.col.y.mean().over("y")) ) .with_columns( pl.col("q1").map_batches(lambda x: [print(f"{x.struct.fields=}"), x][-1]) ) .collect() )
No response
The CSE temp column name ends up as the struct field name - instead of the original LHS expression.
x.struct.fields=['__POLARS_CSER_0x9926168f0d727f4b']
With .collect(comm_subexpr_elim=False)
.collect(comm_subexpr_elim=False)
x.struct.fields=['x']
Correct field name.
main
The text was updated successfully, but these errors were encountered:
map_batches is a red herring:
map_batches
df = pl.LazyFrame({"x": [1, 2], "y": [4, 5]}) (df .with_columns( q1 = pl.struct(pl.col.x - pl.col.y.mean()), q2 = pl.struct(pl.col.x - pl.col.y.mean().over("y")) ) .collect() ).to_dict(as_series=False)
{'x': [1, 2], 'y': [4, 5], 'q1': [{'__POLARS_CSER_0x8af40ccf78f1851d': -3.5}, {'__POLARS_CSER_0x8af40ccf78f1851d': -2.5}], 'q2': [{'__POLARS_CSER_0x8af40ccf78f1851d': -3.0}, {'__POLARS_CSER_0x8af40ccf78f1851d': -3.0}]}
Sorry, something went wrong.
as_struct
ritchie46
Successfully merging a pull request may close this issue.
Checks
Reproducible example
Log output
No response
Issue description
The CSE temp column name ends up as the struct field name - instead of the original LHS expression.
With
.collect(comm_subexpr_elim=False)
Expected behavior
Correct field name.
Installed versions
The text was updated successfully, but these errors were encountered: