Skip to content

BUG: loc with a multi-index and a list incorrectly selecting by position #7349

Closed
@jreback

Description

@jreback

from SO

This is a bug; the first should work like the 2nd (it is incorrectly selecting by position); essentially this is .ix fallback type behavior

In [10]: df = DataFrame(np.arange(12).reshape(-1,1),index=pd.MultiIndex.from_product([[1,2,3,4],[1,2,3]]))

In [11]: df.loc[[1,2]]
Out[11]: 
     0
1 2  1
  3  2

In [12]: df.loc[([1,2],),:]
Out[12]: 
     0
1 1  0
  2  1
  3  2
2 1  3
  2  4
  3  5

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions