3
熊猫GROUPBY我有datafrme上,我的两列执行GROUPBY:直方图与matplotlib
ax = df_all.groupby(['Component', 'SubComponent' ])['SubComponent'].count()
这给我这个:
--------------------------------------------------
| Component | SubComponent| |
--------------------------------------------------
|A |First | 1|
--------------------------------------------------
| |Second | 10|
--------------------------------------------------
| |Third | 6|
--------------------------------------------------
|B |First | 8|
--------------------------------------------------
| |Second | 5|
--------------------------------------------------
| |Third | 17|
--------------------------------------------------
现在我想作一个直方图出的。 每个条都是Component,每个组件将在SubComponents上进行划分,显示每个SubComponent具有不同颜色的出现次数。
是否有简单的方法来完成它与matplotlib.pyploy?
感谢, Submi
谢谢,这似乎很好地工作。 – Submi
你可能知道为什么我无法使用plt.figure(figsize =(10,8))更改此图的大小吗? – Submi
尝试'ax.unstack()。plot.bar(stacked = True,figsize =(10,8))' – jezrael