与DataFrame.pivot
搭配使用DataFrame.plot.bar
:
df.pivot('Year','Month','Views').plot.bar()
如果需要,请rename
在透视后添加月份名称:
month_dict = {1 : "January", 2 : "February", 3 : "March", 4 : "April",
5 : "May" , 6 : "June", 7 : "July", 8 : "August",
9 : "September", 10 : "October" ,11 : "November",12 : "December"}
df.pivot('Year','Month','Views').rename(columns=month_dict).plot.bar()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句