每行 pandas 有多个饼图

问题描述:

我想为每个大洲创建多个饼图,以显示其上所含酒精的百分比.

I would like to create multiple pie chart for each continent to show the alcohol serving with percentage on it.

谢谢

您可以使用 T :

You can use DataFrame.plot.pie with transpose dataframe by T:

df = pd.DataFrame({'beer':[1,2,3],
                   'spirit':[4,5,6],
                   'wine':[7,8,9]}, index=['Africa','Asia','Europe'])

print (df)
        beer  spirit  wine
Africa     1       4     7
Asia       2       5     8
Europe     3       6     9

df.T.plot.pie(subplots=True, figsize=(10, 3))