Skip to content

ERR: reindexed non-included labels on a multiindex are dropped #7886

Closed
@jreback

Description

@jreback

related #4088
related #7867

I think this should raise as this is not clear how this should work (e.g. should you get all the other levels set to nan?)

or see my comment below, maybe just document?

In [11]: s = pd.Series(np.arange(9),index=pd.MultiIndex.from_product([['A','B','C'],['foo','bar','baz']],names=['one','two'])).sortlevel()

In [12]: s
Out[12]: 
one  two
A    bar    1
     baz    2
     foo    0
B    bar    4
     baz    5
     foo    3
C    bar    7
     baz    8
     foo    6
dtype: int64

In [13]: s.reindex(['A','B','D'],level=0)
Out[13]: 
one  two
A    bar    1
     baz    2
     foo    0
B    bar    4
     baz    5
     foo    3
dtype: int64

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsError ReportingIncorrect or improved errors from pandasIndexingRelated 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