You can just index it like other dataframes, but using tuples for the combination of levels:
c.loc[('G', 'P'), :]
However, it is possible that for such indexing operations, the multi-index needs to be sorted (otherwise it can give and exception). You can do this with:
c = c.sortlevel()
And to be correct, c
is not a groupby object, but a DataFrame (you also have pandas GroupBy
objects, but they are the result of a .groupby()
call)