One way is to group “A” and look at groups of size 3:
In [11]: g = df1.groupby(level='A') In [12]: g.size() Out[12]: A one 1 three 3 two 3 dtype: int64 In [13]: size = g.size() In [13]: big_size = size[size>=3] In [14]: big_size Out[14]: A three 3 two 3 dtype: int64
Then you can see which lines have “good” A values, and chop them:
In [15]: good_A = df1.index.get_level_values('A').isin(big_size.index) In [16]: good_A Out[16]: array([False, True, True, True, True, True, True], dtype=bool) In [17]: df1[good_A] Out[17]: bar foo AB three A -1.327977 0.243234 B 1.327977 -0.079051 C -0.832506 1.327977 two A 1.327977 -0.128534 B 0.835120 1.327977 C 1.327977 0.838040
source share