hierarhical multi-index counts in pandas,df.reset_index().groupby('X')['Y'].nunique()