按工作日分组并绘制图形熊猫

时间:2021-07-13 15:15:44

标签: python pandas matplotlib

df1=df.groupby(['usertype','day']).size().reset_index(name='times')

enter image description here

如何按组日和用户类型绘制条形图。

1 个答案:

答案 0 :(得分:0)

我想你想要这个:

days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
>>> df.pivot(index="day", columns="usertype", values="times").reindex(days).plot.bar()

Graph