-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesMultiIndexRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Milestone
Description
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
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesMultiIndexRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version