Non-intuitive behavior when multi-indexing a Series · Issue #35349 · pandas-dev/pandas (original) (raw)

Most likely that is not a bug but intended behavior but I find it quite confusing.

Consider the following example

idx = pd.IndexSlice
s = pd.Series(index=pd.MultiIndex.from_tuples([('A', '0'), ('A', '1'), ('B', '0')]), 
              data=[21, 22, 23])
s.loc[idx['A', :], :]

which gives

A  0    21
   1    22
B  0    23
dtype: int64

while intuitively, one would expect

I would expect the latter because that's what you would get with a pd.DataFrame where the second : is referring to the column index. Not paying attention that the object is a series, gives you a completely different result than if you would have a data frame.