我正在尝试为时间序列数据绘制条形图/计数图:
avg_curr1 = df[df['name'] == 'name1'].groupby(["Week of the Month", "Month"]).count()
print(avg_curr1)
输出:
Week of the Month Month col1 col2 col3 col3 col4
1 10 1055 1055 1055 1055 1055
11 842 842 842 842 842
12 789 789 789 789 789
2 10 668 668 668 668 668
11 846 846 846 846 846
12 802 802 802 802 802
3 10 752 752 752 752 752
11 684 684 684 684 684
12 134 134 134 134 134
4 10 447 447 447 447 447
11 462 462 462 462 462
12 386 386 386 386 386
5 9 58 58 58 58 58
10 265 265 265 265 265
11 140 140 140 140 140
12 230
所以基本上,这些是过去三个月的数值,被分为每个星期。你知道吗
然后我试着:
sns.set(style="darkgrid")
ax = sns.countplot(x="avg_curr1", data=avg_curr1, hue = 'Month')
引发了一个值错误。你知道吗
我是否错误地聚合了数据?提前感谢您的建议!你知道吗
修改图形以获取输出:
如果您想分析每月每周的计数,那么应该使用barplot而不是countplot。你知道吗
相关问题 更多 >
编程相关推荐