我认为您可以使用
nlargest-您可以更改
1为
5:
s = df['Neighborhood'].groupby(df['Borough']).value_counts()print sBoroughBronx Melrose 7Manhattan Midtown12 Lincoln Square 2Staten Island Grant City 11dtype: int64print s.groupby(level=[0,1]).nlargest(1)Bronx Bronx Melrose 7Manhattan Manhattan Midtown 12Staten Island Staten Island Grant City 11dtype: int64
正在创建其他列,指定级别信息



