-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
DataFrame.eval error fixed #59145
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
DataFrame.eval error fixed #59145
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
Core eval alignment algorithms. | ||
""" | ||
|
||
import pandas as pd | ||
from __future__ import annotations | ||
|
||
from functools import ( | ||
|
@@ -144,8 +145,6 @@ def _align_core(terms): | |
obj = ti.reindex(reindexer, axis=axis) | ||
terms[i].update(obj) | ||
|
||
terms[i].update(terms[i].value.values) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this line does fix the bug, nice job! But I'm curious about potential side effects: this line of code converts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure @chaoyihu I have added the test in the respective file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should wait and see if it passes the checks after this revision. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the quick response! I viewed your changes and left new comments. The check failures seem to have been caused by the import line you added to the beginning of You probably should also rebase your branch on For now, I do not think you need to do anything further with If it does, someone with write access will likely come to inspect and merge your code. |
||
|
||
return typ, _zip_axes_from_type(typ, axes) | ||
|
||
|
||
|
@@ -218,3 +217,12 @@ def reconstruct_object(typ, obj, axes, dtype): | |
ret_value = np.array([ret_value]).astype(res_t) | ||
|
||
return ret_value | ||
|
||
# Test with the DataFrame and multiline expression | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move the test to a proper test file? I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't forget to remove this block of code from |
||
df = pd.DataFrame({"first": [9.76, 9.76, 9.76], "last": [9.76, 9.76, 9.76], "pre": [9.75, 9.76, 9.76]}) | ||
|
||
expr = """first_ret = first / pre.fillna(first) - 1.0 | ||
last_ret = last / pre.fillna(first) - 1.0""" | ||
|
||
# Now this should work | ||
df.eval(expr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this import line.