multiple pie chart for each row pandas

后端 未结 2 1999
名媛妹妹
名媛妹妹 2021-01-23 02:49

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

Thank you

2条回答
  •  有刺的猬
    2021-01-23 03:15

    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))
    

提交回复
热议问题