i trying have 2 bars each time in bar chart. x axis has time , y axis has count. each time trying plot 2 bars each id.
id time count 585 10 9 585 11 34 585 12 96 193 10 147 193 11 85 193 12 1
tried below code not desired results. helpful.
thanks in advance !!
y = df1['id'] z = df1['count'] ax = plt.subplot(111) ax.bar(y, z,width=0.2,color='b',align='center') ax.bar(y, z,width=0.2,color='g',align='center') ax.xaxis_date() plt.show()
set_index
+ unstack
df.set_index(['time', 'id']).count.unstack().plot.bar()
this time count
ylabel
ax = df.set_index(['time', 'id']).count.unstack().plot.bar() ax.set_ylabel('count')
Comments
Post a Comment