SHARE
TWEET

Untitled

DrunkMik Feb 19th, 2020 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top