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

Closed
immerrr opened this Issue Jul 31, 2014 · 4 comments

Comments

Projects
None yet
4 participants
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 added this to the 0.15.0 milestone Jul 31, 2014

Contributor

jreback commented Jul 31, 2014

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

Contributor

jreback commented Jul 31, 2014

Member

cpcloud commented Jul 31, 2014

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

immerrr referenced this issue Jul 31, 2014

Merged

API: add 'level' kwarg to 'Index.isin' method #7892

2 of 2 tasks complete

+1

jreback closed this in #7892 Aug 4, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment