-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
eval - 'Call' nodes are not implemented #4893
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
What you've got there doesn't make a whole lot of sense (maybe you're doing something that does and this is just an example): df = DataFrame({'a': [1, 1, 2, 2, 3, 3]})
m = df.a.mean()
df.eval('m') == m
pd.eval('m') == m so just evaluate it in Python. No new features will be added to |
Slightly OT: @glaucouri Just in case that error message is a bit cryptic: A "Call" node is a node in the abstract syntax tree created by parsing Python source. Here is the language reference on callable objects. |
What i'm trying to explain (with my poor english) is that in an eval environment if [a] is a P.Series i expect that i can use a this syntax : ( this is my working program, that users can use for do personalized equations) safe_env = dict( [(k,df[k]) for k in df.keys() ]) Actually, with this solution users can do filtering, grouping and equation in a DataFrame environment. Thank's |
@glaucouri What you've just described is essentially what happens under the hood in |
Closing as stale ... not really a demand for this right now |
Out of curiosity, would a (well-written) pull request adding support for the numexpr intrinsic functions be accepted? I've noticed that there is a variable defined in the expression parser called |
we always accept a well-written PR (even some not so well-written!) :) |
@havoc-io Yes, a PR would be great! To get started (if you haven't already) take a look in Here's an example of what a import ast
from ast import * # forgive the star import here
node = ast.parse('f(a, b, c=1)', mode='eval').body
node.func == Name(id='f', ctx=Load())
node.args == [Name(id='a', ctx=Load()), Name(id='b', ctx=Load())]
node.keywords == [keyword(arg='c', value=Num(n=1))] You could probably skip implementing keyword arguments for now and just implement unary or binary functions to get a feel for how difficult (or not) it would be to do this. |
Eish, this may be a bit complicated actually, given the conditional handling of It may also not be as well-defined as I initially imagined. E.g., would you want the behavior for only the 'numexpr' engine or the 'python' engine as well (with appropriate replacement functions from math or NumPy)? I'm also not sure what the behavior should be if Maybe best to leave this issue dead for now :(. |
@havoc-io There are quite a few details to be worked out here, which is part of the reason I didn't implement these right away. It would be nice to have the
|
I believe numexpr overrides intrinsics so a variable called sin wouldn't work. |
df = P.DataFrame({'a':[1,1,2,2,3,3]})
df.eval("a.mean()")
raise:
NotImplementedError: 'Call' nodes are not implemented
i hope this will be possible
thank's
Gla
The text was updated successfully, but these errors were encountered: