Skip to content

Fixed bug. Added in check for ufunc and evaluates inner expression be… #33613

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

Closed
wants to merge 8 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions pandas/core/computation/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,19 +670,26 @@ def visit_Call(self, node, side=None, **kwargs):
)

return res(*new_args)
elif isinstance(res, np.ufunc):
new_args = [self.visit(arg) for arg in node.args]
new_args = str(*new_args)
new_args = [eval(new_args)]

if node.keywords:
raise TypeError(
f'Function "{res.name}" does not support keyword arguments'
)
else:

new_args = [self.visit(arg).value for arg in node.args]

for key in node.keywords:
if not isinstance(key, ast.keyword):
raise ValueError(f"keyword error in function call '{node.func.id}'")
for key in node.keywords:
if not isinstance(key, ast.keyword):
raise ValueError(f"keyword error in function call '{node.func.id}'")

if key.arg:
kwargs[key.arg] = self.visit(key.value).value
if key.arg:
kwargs[key.arg] = self.visit(key.value).value

return self.const_type(res(*new_args, **kwargs), self.env)
return self.const_type(res(*new_args, **kwargs), self.env)

def translate_In(self, op):
return op
Expand Down Expand Up @@ -815,3 +822,5 @@ def names(self):


_parsers = {"python": PythonExprVisitor, "pandas": PandasExprVisitor}