Making a clustered bar chart, Pandas

后端 未结 3 1578
悲哀的现实
悲哀的现实 2021-01-22 11:35

I have a little pandas dataframe that looks like this:

    Word   Percentage1  Percentage2
1   drink   18.166654   29.014272
2   cherry  13.498262   12.802642
3          


        
3条回答
  •  执念已碎
    2021-01-22 12:05

    You can choose stacked bar graph:

    # Given
    df = pd.DataFrame({'word':['Alpha', 'Bravo', 'Charlie'],
                      'Percentage 1':[10, 3, 0],
                      'Percentage 2': [5, 6, 4]})
    
    df.set_index('word').plot(kind='barh', stacked=True)
    

提交回复
热议问题