I have a pd.DataFrame
of the following form and numerical values in column 0 are not necessarily distinct:
>>> idx = pd.MultiIndex.from_arrays([["a", "a", "b", "b", "c", "c"], ["b", "c", "a", "c", "a", "b"]])
>>> df = pd.DataFrame(list(range(6)), index=idx)
0
a b 0
c 1
b a 2
c 3
c a 4
b 5
I would like to slice out first occurrences of unique combinations of the 2 index levels to get something like this:
0
a b 0
c 1
b c 3
Using pandas
0.23.4 and Python 3.6.5 in this case.