[英]draw a grouped bar graph from a dataframe originated from an sql query grouped on multiple attributes
I'm relatively new to pandas and numpy我对 pandas 和 numpy 比较陌生
what I'm trying to achieve is:我想要实现的是:
Following there is a sample dataframe:下面是一个示例 dataframe:
name message occurred
0 meta-tag1 InvalidPlan 1
1 meta-tag1 Maximun number of attempts at planning surpassed 276
2 meta-tag1 Rescheduling worker 275
3 meta-tag2 InvalidPlan 18
4 meta-tag3 Maximun number of attempts at planning surpassed 22
I can't seem to find a solution that allows me to produce the result I want.我似乎找不到让我产生我想要的结果的解决方案。
At first I used np.unique to build 2 lists containing the unique meta-tags and unique error起初,我使用 np.unique 构建了 2 个包含唯一元标记和唯一错误的列表
Then generating a list of dataframes filtered for meta-tag, then generating an array from each sub-dataframe containing only the occurences per error and I tried feeding to a pyplot feeding it the list of arrays with the occurrencies, the unique error-messages as columns and unique meta-tags as index, but I couldn't get it working and I am pretty sure it's the wrong approach at it.然后生成为元标记过滤的数据帧列表,然后从每个子数据帧生成一个数组,其中仅包含每个错误的出现次数,我尝试将其提供给一个 pyplot,将 arrays 列表提供给它,其中的唯一错误消息为列和唯一的元标记作为索引,但我无法让它工作,我很确定这是错误的方法。
I'm pretty sure it can be achieved only by manipulating the dataframe in the correct way, which it's pretty hard for me at my current level, any suggestion is really really welcome.我很确定它只能通过以正确的方式操作 dataframe 来实现,这对我目前的水平来说非常困难,任何建议都非常受欢迎。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.