-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: sqrt not implemented in df.eval #7677
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
Well, its This is applies to function calls in general in |
Hi, Do you have suggestions? |
https://github.com/pydata/pandas/blob/master/pandas/computation/expr.py hmm, this IS implemented. So might be buggy somewhere. in the debugger step thru this and see if you can see where/why this is rejected. |
the parser disallows function calls by original design, mostly for time reasons but this could be opened up. there's a |
@jreback that implementation is only used by the pytables engine |
@cpcloud right....this was a while ago. yes I remember now, the arbitrary functions have to be done in python space, so was a bit complicated (e.g. have to validate which are numexpr capable and which are not). |
@acorbe this is a bit non-trivial. but would love some eyes on it! this is actually a pretty interesting thing to understand, you get to learn AST parsing, and numexpr internals ( maybe +1 or -1) by your definition ! |
@acorbe just a bit of what's going on to (maybe?) whet your appetite: An expression like: a ** .5 which as you show parses to (a) ** (.5) eventually goes into numexpr (effectively) as numexpr.evaluate('(df.a.values) ** (0.5)') Since With function calls, the parsing is more complicated (though most of the code necessary to do it is already there thanks to @jreback), but Python has the
There's a lot going in |
Hi people, thanks for your explanations! I must say that when I mentioned it as a bug I had a look at numexpr reference. Since I cannot promise this much time to look at this, sorry :(. |
Any progress on this? If not I will have a look to see if I can help |
@Twizzledrizzle please dive in if you get a chance! I'm not sure when I'll be able to get to this |
Hmmm.... _unsupported_nodes contain (expr.py row ~316)
cannot find where it get stuck on that 'Call' nodes are not implemented. Can you point me closer to the problem?? Sorry much of this code is currently new to me :) |
In this function, the 'Call' node is included when I print the node. Can it be included here?
|
I am also not sure how the engine works in eval.py, line 211. When I push a hard coded 'sqrt(2)' for instance instead of parsed_expr. It still does not work. Do you know what string is required to make the engine work? I guess one simple way of making it work, is turning all 'sqrt(....)' into '(....)**0.5' |
The same problem with log function. |
this was closed by #10953 and is available in 0.17.0 |
In the following scenario:
This call doesn't work (while it is supposed to, I guess)
while this one does
I guess this is a bug.
The text was updated successfully, but these errors were encountered: