Counting unique index values in Pandas groupby,ex.groupby(level='A').agg(lambda x: x.index.get_level_values(1).nunique())