您正在寻找
pivot_table:
In [11]: medals = df.pivot_table('no of medals', ['Year', 'Country'], 'medal')In [12]: medalsOut[12]:medal Bronze Gold SilverYear Country1896 Afghanistan 3 5 4 Algeria3 1 2
以及是否要重新排列列:
In [12]: medals.reindex_axis(['Gold', 'Silver', 'Bronze'], axis=1)Out[12]:medal Gold Silver BronzeYear Country1896 Afghanistan 5 4 3 Algeria 1 2 3
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)