1
條形圖上添加值標籤當我打印使用matplotlib
graph_by_users = users.pivot(index='address', columns='used_at', values='users')
我得到
address used_at time online
0 am.ru 2014 114.741944
1 am.ru 2015 50.945000
2 auto.ru 2014 2533.983889
3 auto.ru 2015 1923.157500
4 avito.ru 2014 23473.097500
5 avito.ru 2015 24357.936389
6 avtomarket.ru 2014 29.680278
7 avtomarket.ru 2015 26.646389
8 cars.mail.ru/sale 2014 58.737778
9 cars.mail.ru/sale 2015 46.466111
10 drom.ru 2014 3059.709722
11 drom.ru 2015 2695.590000
12 e1.ru 2014 7966.210278
13 e1.ru 2015 7767.182500
14 irr.ru/cars 2014 61.720278
15 irr.ru/cars 2015 37.132778
我需要打印條形圖
ax = graph_by_duration.plot.bar(width=0.5, ax=axes[0])
ax1 = graph_by_duration.plot.bar(width=0.8)
rects = ax1.patches
labels = ["%d" % i for i in time['time online']]
for rect, label in zip(rects, labels):
height = rect.get_height()
ax1.text(rect.get_x() + rect.get_width()/2, height + 5, label,
ha='center', va='bottom')
它把值2014
和之後到2015
。但這是錯誤的,因爲在我的數據框中意味着混合
謝謝您的回答!有用 – ldevyataykina