Skip to content

API: add 'level' kwarg for Index.isin method #7890

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
immerrr opened this issue Jul 31, 2014 · 4 comments · Fixed by #7892
Closed

API: add 'level' kwarg for Index.isin method #7890

immerrr opened this issue Jul 31, 2014 · 4 comments · Fixed by #7892
Labels
API Design Enhancement Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Milestone

Comments

@immerrr
Copy link
Contributor

immerrr commented Jul 31, 2014

xref #7886

It would be nice to be able to write:

s[s.index.isin(['a', 'b', 'c'], level='foo')]

instead of

s[s.index.get_level_values('foo').isin(['a', 'b', 'c'])]

The former variant is not only shorter but is also potentially more performant: one only has to look up levels in given container and then operate on labels only avoiding instantiation of sub-index completely.

Default value should be None, plain Index objects should only accept None, 0, and, Index.name for the sake of consistency (the last one is especially arguable).

@jreback jreback added this to the 0.15.0 milestone Jul 31, 2014
@jreback
Copy link
Contributor

jreback commented Jul 31, 2014

ok, I think if we put this in we can then revert #7867

@jreback
Copy link
Contributor

jreback commented Jul 31, 2014

@cpcloud @jorisvandenbossche thoughts?

@cpcloud
Copy link
Member

cpcloud commented Jul 31, 2014

👍 here, also agree on @immerrr's choice of defaults.

@jorisvandenbossche
Copy link
Member

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants