Skip to content

BUG: multiindex slice 1.1.0rc0 #35351

Closed
@leo4183

Description

@leo4183

mulitindex slicing returns different (from pandas<=1.0.x) results in pandas 1.1.0rc0

df = pd.DataFrame( data=[[0,1,'a',1],[1,0,'a',0],[1,1,'b',1],[1,1,'c',2]], columns=['index','date','author','price'] )

# to keep the most recent date for every index (could happen in practice)
idx = df.drop_duplicates('index',keep='last').set_index(['index','date']).index 

df.set_index(['index','date']).loc[idx,:].reset_index()

df

 index date  author price
0 1 a 1
1 0 a 0
1 1 b 1
1 1 c 2

Result

author price
(0, 1) a 1
(1, 1) b 1
(1, 1) c 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndexRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions