来自数据框的多线图
从数据框架中,我需要按月绘制事件计数,以了解在给定一个月内更有可能发生哪些事件。我不知道如何使用列计数。
df["MONTH"]= pd.to_datetime(df["BEGIN_DATE_TIME"], format = "%m/%d/%Y").dt.month
montly_events =df.groupby(["EVENT_TYPE", "MONTH"]).size().astype(int)
montly_events2 = montly_events.to_frame(name = "Count").reset_index()
plt.figure(figsize =(15,3))
sns.lineplot(x="MONTH", y="EVENT_TYPE", palette="ch:.25", data=df)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iiuc,计数是您的DF中的另一列,尝试将其作为“ y”,您在此包含的截图作为屏幕截图
尝试
IIUC, count is another column in your df, try to make that as a 'y', the one that you have included here as screenshot
Try
这是我使用一个Barplot发现的解决方案:
This was the solution I found using a barplot: