Skip to content

API/ENH: enable boolean indexing conditions to reference its input frame via eval #5501

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
jreback opened this issue Nov 12, 2013 · 10 comments
Closed

Comments

@jreback
Copy link
Contributor

jreback commented Nov 12, 2013

http://stackoverflow.com/questions/19938734/is-there-a-simple-way-to-reference-the-current-object-after-applying-a-chain-of

df.where("A>0",1)
df.loc["A>0"]

so could process the condition via an 'eval' type of operation

@jreback
Copy link
Contributor Author

jreback commented Nov 12, 2013

@cpcloud might be interesting

@jonblunt
Copy link

When I posted on stackoverflow I was thinking of a "magic" character/name that would stand for the parent object.

eg
ts.where( '_ > 0 )

having '_'stand for the object upon which the method is called. Often in my usage the object is an unnamed series.

The eval syntax works when the calling object is a DataFrame and the columns have names that can be intuited from the previous action, but an unnamed series has no name.

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Feb 18, 2014
@cpcloud
Copy link
Member

cpcloud commented Mar 16, 2014

I seem to be missing these kinds of things....guess I should look at the "mentioning you" more often... @jreback sorry about that

@jreback
Copy link
Contributor Author

jreback commented Mar 16, 2014

ha! though I think needs some thinking about

@cpcloud
Copy link
Member

cpcloud commented Mar 16, 2014

@jreback what do u think about the _ idea from @jonblunt? i think u could just pass to query and have _ mean self, no?

@jreback
Copy link
Contributor Author

jreback commented Mar 16, 2014

sure but then I'll bet people would want it for regular usage (non query/eval)

prob a reasonable idea though

@cpcloud
Copy link
Member

cpcloud commented Mar 16, 2014

oh i c now u wanted to have string input used in query and whatever the query was eval it on the caller

@cpcloud
Copy link
Member

cpcloud commented Mar 16, 2014

but that happens anyway ... you can chain as much as you want, but you must refer to either cols or locals

@jreback
Copy link
Contributor Author

jreback commented Mar 3, 2015

hmm, can now do this by using .assign (as an input to .query), though not explicity supported in eval

@jreback jreback modified the milestones: Someday, 0.16.0 Mar 3, 2015
@jreback
Copy link
Contributor Author

jreback commented May 24, 2016

closed by #12539

@jreback jreback closed this as completed May 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants