Advertisement
DrunkMik

Untitled

Feb 19th, 2020
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. data_platform = games.pivot_table(index = 'platform',aggfunc = {'year_of_release':['min', 'max'], 'sales':'sum'})
  2. data_platform['years_old'] = data_platform['year_of_release', 'max'] - data_platform['year_of_release', 'min']
  3. data_platform = data_platform.reset_index()
  4. data_platform.columns = ['platform','sales_sum','first_year', 'last_year', 'years_old']
  5. data_platform = data_platform.sort_values(by = 'first_year', ascending = True)
  6. def dff(row):
  7.     return row['platform'] + ' ' + str(row['first_year'])
  8.  
  9. data_platform['platform1'] = data_platform.apply(dff,axis=1)
  10.  
  11. ax = data_platform.plot(kind = 'barh', grid = True, figsize = (15,10), y = 'years_old', x = 'platform1',\
  12.                        color=['teal', 'red', 'green', 'blue', 'cyan'])
  13. plt.xticks(data_platform[('years_old')])
  14. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement