python - 通过 value_counts() 创建箱线图 [发生的事件数]
问题描述
我有以下数据框。每个条目都是一个发生的事件 [550624 个事件]。假设我们对每月每天发生的事件数量的箱线图感兴趣。
print(df)
Month Day
0 4 1
1 4 1
2 4 1
3 4 1
4 4 1
... ...
550619 10 31
550620 10 31
550621 10 31
550622 10 31
550623 10 31
[550624 rows x 2 columns]
df2 = df.groupby('Month')['Day'].value_counts().sort_index()
Month Day
4 1 2162
2 1564
3 1973
4 1620
5 1860
10 27 2022
28 1606
29 1316
30 1674
31 1726
sns.boxplot(x = df2.index.get_level_values('Month'), y = df2)
我的问题是这种方式是否是创建这种视觉信息的最有效/直接的方式,或者我是否正在采取一种迂回的方式来实现这一点。有没有更直接的方法来实现这种视觉效果?
解决方案
推荐阅读
- javascript - 将查询到的数据赋值给div中的变量
- html - 具有固定高度的图像和文本并排的 HTML
- ajax - XERO API Develop 向我展示 Request TenantId 签证 ajax 请求时的跨域
- json - 嵌套的 JSON 消息未通过 logstash 正确解析
- javascript - 如何在 Jest 中为“抛出”断言实现干净的测试报告
- javascript - 不再呈现组件后运行的函数(React)
- vba - VBA - 手动双面打印
- jquery - 如何在不计算值的情况下将日期传递给函数 jQuery?
- javascript - 有没有更快的方法来删除文档上的所有 keyup eventListeners
- java - Android:如何更新获取用户信息的进度条?