Suppose I have a DataFrame with two MultiIndex levels, such as:
col1
A x 1
y 2
B x 3
y 4
C x 5
Now, if an index of the level 0 lacks the lower level index 'x' or 'y', I want to drop all rows associated with this index. So in this example I want to drop all rows of 'C' because there is no 'y' under 'C'. So the result should be:
col1
A x 1
y 2
B x 3
y 4
Is there a nice/clean way to do this?