I found a weird behaviour when slicing on multiindex where the index is a tuple
tmp=pd.Series(0,index=pd.MultiIndex.from_tuples([
(('a',),),
(('b',),),
(('c','cc'),),
(('d','dd'),),
]))
print(tmp.reindex(tmp.index[1:]))
yields the following results
(b,) 0.0
(c, cc) NaN
(d, dd) NaN
Am I using the multiIndex incorrectly or is it a bug? (pandas version='1.1.0')
CodePudding user response:
Your code works well with a recent version of Pandas.
Output:
# pd.__version__: '1.4.1'
>>> tmp.reindex(tmp.index[1:])
(b,) 0
(c, cc) 0
(d, dd) 0
dtype: int64
Is it what you expect?