大熊猫绘制一组
问题描述:
我想绘制TE以下数据至极是唯一的文本代码大熊猫绘制一组
Element
Motor 1 thermiek 15
tijd te lang 9
Motor 2 thermiek 12
tijd te lang 3
Motor 3 thermiek 5
tijd te lang 4
dtype: int64
by_element = data.groupby('Element')
by_element['Alarm tekst'].value_counts().plot(kind='bar')
结果的计数
我怎样才能使情节等进行分组:
答
这应该工作得到一个类似于您的评论中链接的分组条形图:
gb = df.groupby(['Element','Alarm tekst'])
gb['Alarm tekst'].count().unstack().plot(kind = 'bar')
就是聚合条原建议:
您应该包括agg()
函数计算的总价值。
data.groupby('Element').agg('count').plot(kind = 'bar')
如果你的第二个栏已经被长期总结,你可以使用agg(numpy.sum)
代替:
import numpy
data.groupby('Element').agg(numpy.sum).plot(kind = 'bar')
我不希望他们被加入了,我想是这样http://pandas.pydata.org /pandas-docs/version/0.15.0/_images/bar_plot_multi_ex.png – rienverbeke 2015-04-04 20:45:31
我的错误,请参阅我更新的答案。 – 2015-04-04 21:03:15
非常感谢 – rienverbeke 2015-04-04 21:09:39