Skip to content
New issue

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

pl.when('a').then(-pl.col.b) creates a column called "literal", even though its meta.output_name() is "b" #11220

Closed
2 tasks done
Wainberg opened this issue Sep 21, 2023 · 2 comments
Labels
bug Something isn't working python Related to Python Polars

Comments

@Wainberg
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

>>> pl.DataFrame({'a': [True, False], 'b': [1, 2]}).select(pl.when('a').then(pl.col.b))
 b
 1
 null
shape: (2, 1)
>>> pl.DataFrame({'a': [True, False], 'b': [1, 2]}).select(pl.when('a').then(-pl.col.b))
 literal
 -1
 null
shape: (2, 1)
>>> pl.when('a').then(-pl.col.b).meta.output_name()
'b'

Log output

No response

Issue description

pl.when('a').then(-pl.col.b) creates a column called "literal", even though its meta.output_name() is "b".

Expected behavior

The column name should be "b", no?

Installed versions

--------Version info---------
Polars:              0.19.3
Index type:          UInt32
Platform:            Linux-3.10.0-1160.88.1.el7.x86_64-x86_64-with-glibc2.17
Python:              3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]

----Optional dependencies----
adbc_driver_sqlite:  <not installed>
cloudpickle:         <not installed>
connectorx:          <not installed>
deltalake:           <not installed>
fsspec:              <not installed>
gevent:              <not installed>
matplotlib:          3.8.0
numpy:               1.26.0
pandas:              2.1.1
pyarrow:             13.0.0
pydantic:            <not installed>
sqlalchemy:          <not installed>
xlsx2csv:            0.8.1
xlsxwriter:          3.1.4
@Wainberg Wainberg added bug Something isn't working python Related to Python Polars labels Sep 21, 2023
@reswqa
Copy link
Collaborator

reswqa commented Sep 21, 2023

This maybe already fixed in main branch.

@alexander-beedie
Copy link
Collaborator

Can confirm that this was fixed by #11158; will be in the upcoming 0.19.4 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

3 participants