-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
'BinOp' object has no attribute 'value' Issue while calling global functions in eval and importing numpy #24670
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
Comments
Thanks for the report. Investigation and PRs are always welcome |
take |
After looking at the documentation, I noticed that evaluating global functions is not an explicit property of pd.eval(). However, it does seem like a useful addition and something that should be a property of the function. @WillAyd can we also add a request to update documentation? |
This looks to work on master, I suppose it could use a test.
|
@mroeschke I downloaded and setup the latest master branch locally to test this, and didn't get it to work. Using: import pandas as pd
from numpy import *
print("Version:", pd.__version__)
print()
r = pd.eval("floor(1)")
print("Test1:", r)
r = pd.eval("floor(1+5)")
print("Test2:", r) I still get the original error: Version: 1.1.0.dev0+1575.gee1efb6d9
Test1: 1.0
Traceback (most recent call last):
File "test_pd_parse.py", line 10, in <module>
r = pd.eval("floor(1+5)")
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\eval.py", line 341, in eval
parsed_expr = Expr(expr, engine=engine, parser=parser, env=env)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 787, in __init__
self.terms = self.parse()
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 806, in parse
return self._visitor.visit(self.expr)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 398, in visit
return visitor(node, **kwargs)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 404, in visit_Module
return self.visit(expr, **kwargs)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 398, in visit
return visitor(node, **kwargs)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 407, in visit_Expr
return self.visit(node.value, **kwargs)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 398, in visit
return visitor(node, **kwargs)
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 677, in visit_Call
new_args = [self.visit(arg).value for arg in node.args]
File "c:\users\vmuriart\desktop\pandas\pandas\pandas\core\computation\expr.py", line 677, in <listcomp>
new_args = [self.visit(arg).value for arg in node.args]
AttributeError: 'BinOp' object has no attribute 'value' |
@mroeschke The issue is raised if you include the line:
|
I've just found out that this issue can be caused by trying to parse formulas referring to an empty pandas df column (i.e. column entirely composed of
raises
if:
|
The text was updated successfully, but these errors were encountered: