制作聚集条形图,Pandas [英] Making a clustered bar chart, Pandas

查看:62
本文介绍了制作聚集条形图,Pandas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的小熊猫数据框:

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   berry   9.810123    6.775552
4   plum    7.964429    7.105845
5   crisp   7.892941    4.715009
...
50  spices  0.856775    1.663586

词 (50) 和带有数字的两列,每一列都表示该词的发生率.如何制作聚类图表以显示每个单词的两个数字的比较?我已经尝试了几乎所有在本网站上提供给其他人的代码,我只是不明白如何将两个百分比"列分组.

Words (50) and the two columns with figures corresponding to every one of them signifying the incidence of the word. How do I make a clustered chart to show the comparison of the two figures for each word? I have tried virtually every piece of code that was offered to other people on this site, I just don't understand how to group the two "Percentage" columns.

推荐答案

如果我理解正确的话,你可以这样做:

If I understand you correctly, you can do in this way:

df.plot(x="Word", y=["Percentage1", "Percentage2"], kind="bar")

这篇关于制作聚集条形图,Pandas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆