Closed
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
s = pd.Series([1, 2], pd.MultiIndex.from_arrays([['a', 'b']]))
print(s.loc[['a', 'a', 'b', 'b']])
Problem description
This prints the full series, not the series with repeated elements:
a 1
b 2
dtype: int64
Expected Output
a 1
a 1
b 2
b 2
dtype: int64
An easy work around is to use s.reindex(['a', 'a', 'b', 'b'])
instead. But loc
and reindex
should return the same thing when all labels are found.
Output of pd.show_versions()
pandas 0.22.0
I think this behavior is present on earlier versions of pandas, too, but previously it was very difficult to construct a MultiIndex with only a single level, because they were automatically turned in a base Index.