`.loc` and `.iloc` with MultiIndex'd DataFrame
Yes, this is a deliberate design decision:
.iloc
is a strict positional indexer, it does not regard the structure at all, only the first actual behavior. ....loc
does take into account the level behavior. [emphasis added]
So the desired result given in the question is not possible in a flexible manner with .iloc
. The closest workaround, used in several similar questions, is
print(df.loc[[df.index.get_level_values(0)[-1]]])
0 1 2 3
first second
qux one -1.25388 -0.63775 0.90711 -1.42868
two -0.14007 -0.86175 -0.25562 -2.79859
Using double brackets will retain the first index level.