Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. pivot_to_plot = (data
  2.     .pivot_table(index='locality_name' , values='price_per_area', aggfunc=('count', 'mean'))
  3.     .sort_values('count', ascending=False)
  4.     .head(10)
  5. )
  6.  
  7. plt.figure(figsize=(20,10))
  8. plt.title('Средняя стоиомсть метра и количество объектов')
  9.  
  10. ax1 = pivot_to_plot['count'].plot(kind = 'bar',color='blue', grid=True, label='Count')
  11. ax2 = pivot_to_plot['mean'].plot(color='red', grid=True, secondary_y=True, label='Mean')
  12.  
  13. #строим легенду
  14. h1, l1 = ax1.get_legend_handles_labels()
  15. h2, l2 = ax2.get_legend_handles_labels()
  16. plt.legend(h1+h2, l1+l2, loc=1)
  17.  
  18. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement