application_vnd.jupyter.stderr_output_1.png
import pandas as pd

spotify = pd.read_csv('C:\\Users\\KK\\Documents\\Kitu\\College\\Senior Year\\Extracurriculars\\Python\\Spotify\\.spyproject\\data.csv')

spotify.shape
spotify.dtypes

spotify.Region = spotify.Region.astype('category')
spotify.Date = pd.to_datetime(spotify['Date'])
spotify.dtypes

globe = spotify[spotify.Region == 'global']
usa = spotify[spotify.Region == 'us']
great_britain = spotify[spotify.Region == 'gb']
mexico = spotify[spotify.Region == 'mx']
taiwan = spotify[spotify.Region == 'tw']
singapore = spotify[spotify.Region == 'sg']

top_globe = globe.groupby('Track Name').agg({'Streams': 'sum'})
top_globe = top_globe.sort_values(['Streams'], ascending=False)
top_globe['country'] = 'Globe'
top_usa = usa.groupby('Track Name').agg({'Streams': 'sum'})
top_usa = top_usa.sort_values(['Streams'], ascending=False)
top_usa['country'] = 'USA'
top_great_britain = great_britain.groupby('Track Name').agg({'Streams': 'sum'})
top_great_britain = top_great_britain.sort_values(['Streams'], ascending=False)
top_great_britain['country'] = 'Great Britain'
top_mexico = mexico.groupby('Track Name').agg({'Streams': 'sum'})
top_mexico = top_mexico.sort_values(['Streams'], ascending=False)
top_mexico['country'] = 'Mexico'
top_taiwan = taiwan.groupby('Track Name').agg({'Streams': 'sum'})
top_taiwan = top_taiwan.sort_values(['Streams'], ascending=False)
top_taiwan['country'] = 'Taiwan'
top_singapore = singapore.groupby('Track Name').agg({'Streams': 'sum'})
top_singapore = top_singapore.sort_values(['Streams'], ascending=False)
top_singapore['country'] = 'Singapore'

top_globe2 = globe.groupby('Artist').agg({'Streams': 'sum'})
top_globe2 = top_globe2.sort_values(['Streams'], ascending=False)
top_globe2['country'] = 'Globe'
top_usa2 = usa.groupby('Artist').agg({'Streams': 'sum'})
top_usa2 = top_usa2.sort_values(['Streams'], ascending=False)
top_usa2['country'] = 'USA'
top_great_britain2 = great_britain.groupby('Artist').agg({'Streams': 'sum'})
top_great_britain2 = top_great_britain2.sort_values(['Streams'], ascending=False)
top_great_britain2['country'] = 'Great Britain'
top_mexico2 = mexico.groupby('Artist').agg({'Streams': 'sum'})
top_mexico2 = top_mexico2.sort_values(['Streams'], ascending=False)
top_mexico2['country'] = 'Mexico'
top_taiwan2 = taiwan.groupby('Artist').agg({'Streams': 'sum'})
top_taiwan2 = top_taiwan2.sort_values(['Streams'], ascending=False)
top_taiwan2['country'] = 'Taiwan'
top_singapore2 = singapore.groupby('Artist').agg({'Streams': 'sum'})
top_singapore2 = top_singapore2.sort_values(['Streams'], ascending=False)
top_singapore2['country'] = 'Singapore'

top_globe2 = top_globe2[0:3]
top_usa2 = top_usa2[0:3]
top_great_britain2 = top_great_britain2[0:3]
top_mexico2 = top_mexico2[0:3]
top_taiwan2 = top_taiwan2[0:3]
top_singapore2 = top_singapore2[0:3]