Python 熊猫数据框条形图-定性变量?
我希望创建一个简单的条形图,其中“源”的分组定性值是x轴,“转发计数”的定量值是y轴 我想要按来源的转发总数Python 熊猫数据框条形图-定性变量?,python,matplotlib,pandas,dataframe,Python,Matplotlib,Pandas,Dataframe,我希望创建一个简单的条形图,其中“源”的分组定性值是x轴,“转发计数”的定量值是y轴 我想要按来源的转发总数 _id created_at geo id retweet_count source text 0 52c2388a0b434a166c94a648 2013-12-31 03:22:30 None 417858271957893121 0 web
_id created_at geo id retweet_count source text
0 52c2388a0b434a166c94a648 2013-12-31 03:22:30 None 417858271957893121 0 web @sirenasmaster I'm one of 4 people that I foll...
1 52c2388a0b434a166c94a649 2013-12-31 03:22:29 None 417858271350120449 0 Twitter for iPhone Thanks Mack brown always looked up to you and ...
2 52c2388a0b434a166c94a64a 2013-12-31 03:22:26 None 417858255121948672 0 Twitter for iPhone @CottonGent I never said case was awesome, but...
3 52c2388a0b434a166c94a64b 2013-12-31 03:22:20 None 417858229625163776 0 buzztap Longhorn Digest (Scout) >> UA Game: DB C...
4 52c2388a0b434a166c94a64c 2013-12-31 03:22:15 None 417858211186626560 1 web RT @rudyp_: Marvin is on it tonight. He's a tr...
5 52c2388a0b434a166c94a64d 2013-12-31 03:22:12 None 417858197550931970 2 Twitter for iPhone RT @marvintran76: If you're a Longhorn and you...
6 52c2388a0b434a166c94a64e 2013-12-31 03:21:49 None 417858102042443776 1 Twitter for iPhone Always will be a Longhorn Fan You can groupby and plot then:
>>> df.groupby('source')['retweet_count'].sum().plot(kind='bar')
<matplotlib.axes.AxesSubplot object at 0x039C8070>
\u id已创建\u在geo id retweet\u count源文本
您必须遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他有关法律法规。。。
1 52c2388a0b434a166c94a649 2013-12-31 03:22:29无417858271350120449 0 iPhone推特谢谢Mack brown一直很尊敬你。。。
2 52c2388a0b434a166c94a64a 2013-12-31 03:22:26无417858255121948672 0 iPhone@CottonGent的推特我从来没说过这个案例很棒,但是。。。
3 52c2388a0b434a166c94a64b 2013-12-31 03:22:20无417858229625163776 0 buzztap Longhorn Digest(Scout)>>UA游戏:DB C。。。
4 52c2388a0b434a166c94a64c 2013-12-31 03:22:15今晚没有4178582111866626560一个web RT@rudyp_:Marvin在节目中。他是一个。。。
5 52c2388a0b434a166c94a64d 2013-12-31 03:22:12无417858197550931970 2 iPhone推特RT@marvintran76:如果你是长角牛,你。。。
6 52c2388a0b434a166c94a64e 2013-12-31 03:21:49无417858102042443776 1 iPhone推特永远是一个长角粉丝你可以分组并绘制:
>>df.groupby('source')['retweet\u count'].sum().plot(kind='bar'))
谢谢,这很有效。我深夜的尝试离这很近。