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

pd.eval: Series names are now preserved even for "numexpr" engine. #58437

Merged
merged 4 commits into from Apr 29, 2024

Conversation

domsmrz
Copy link
Contributor

@domsmrz domsmrz commented Apr 25, 2024

Series names are now preserved even when using
numexpr engine. Making the behavior consistent
with python engine.

Series names are now preserved even when using
numexpr engine. Making the behavior consistent
with python engine.
Comment on lines +209 to +210
return typ(obj, dtype=res_t, **axes)
return typ(obj, dtype=res_t, name=name, **axes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't name=None also be OK? i.e. Can't this always be return typ(obj, dtype=res_t, name=name, **axes)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately no. In some cases typ is DataFrame (in particular cases like pd.eval("df + df")) in which case passing anything as name= (including None) would raise a TypeError

@mroeschke mroeschke added the expressions pd.eval, query label Apr 29, 2024
domsmrz and others added 3 commits April 29, 2024 20:47
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
@mroeschke mroeschke added this to the 3.0 milestone Apr 29, 2024
@mroeschke mroeschke merged commit 2246a78 into pandas-dev:main Apr 29, 2024
46 checks passed
@mroeschke
Copy link
Member

Thanks @domsmrz

@domsmrz domsmrz deleted the fix-eval-name branch April 29, 2024 20:43
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…ne. (pandas-dev#58437)

* Eval: Series names are preserved for numexpr

Series names are now preserved even when using
numexpr engine. Making the behavior consistent
with python engine.

* Update doc/source/whatsnew/v3.0.0.rst

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>

* Update pandas/core/computation/align.py

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>

* Update pandas/tests/computation/test_eval.py

---------

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expressions pd.eval, query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: numexpr eval doesn't hold column name via single column selection
2 participants