Skip to content

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

Closed
@immerrr

Description

@immerrr

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions