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