import json
with open('/content/drive/MyDrive/projects/music_data/artists_ids_IN.json') as id_file:
artist_ids = json.load(id_file)
list(artist_ids.keys())
with open('/content/drive/MyDrive/projects/music_data/data_artists_IN.json') as data_file:
artist_data = json.load(data_file)
album_name = [album_info['album_name'] for key in artist_data for album_info in artist_data[key][0]['albums_full']]
album_popularity = [album_info['album_popularity'] for key in artist_data for album_info in artist_data[key][0]['albums_full']]
album_artists = [album_info['album_artists'] for key in artist_data for album_info in artist_data[key][0]['albums_full']]
release_date = [album_info['release_date'][0:4] for key in artist_data for album_info in artist_data[key][0]['albums_full']]
import pandas as pd
dict_album = dict(list(zip(['album_name','album_artists','release_date', 'album_popularity'],[album_name,album_artists,release_date, album_popularity])))
df_album = pd.DataFrame(data=dict_album)
df_album
album_name | album_artists | release_date | album_popularity | |
---|---|---|---|---|
0 | 'Hop Stomp' | When Chai Met Toast | 2019 | 29 |
1 | Run Closer - Single | When Chai Met Toast | 2018 | 36 |
2 | Die Trying (The Album) | Kenny Sebastian | 2018 | 22 |
3 | Karam (Equals Sessions) - Single | Rangle Sardar | 2019 | 27 |
4 | Nee Aara | When Chai Met Toast | 2019 | 32 |
... | ... | ... | ... | ... |
24649 | World Tour - Bombay Lounge | Various Artists | 2008 | 6 |
24650 | Sumud - The Acoustic EP | Niyaz | 2013 | 2 |
24651 | Republic Day Special 2019 | Various Artists | 2019 | 10 |
24652 | Hits Of Alia Bhatt | Various Artists | 2018 | 18 |
24653 | Chillax Summer Collection | Various Artists | 2014 | 1 |
24654 rows × 4 columns
import seaborn as sns
df_release = df_album.groupby('release_date',as_index=False).count()
df_release['number_of_albums']=df_release['album_name']
df_release_new = df_release.drop(['album_name','album_artists','album_popularity'],axis=1)
df_release_new
release_date | number_of_albums | |
---|---|---|
0 | 0000 | 2 |
1 | 1937 | 2 |
2 | 1939 | 3 |
3 | 1940 | 1 |
4 | 1941 | 1 |
... | ... | ... |
79 | 2016 | 1579 |
80 | 2017 | 1532 |
81 | 2018 | 1561 |
82 | 2019 | 1792 |
83 | 2020 | 1634 |
84 rows × 2 columns
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(16, 6))
sns.barplot(x='release_date',y='number_of_albums',data=df_release_new)
ax.set_xticks(ax.get_xticks()[::10]);
df_album.to_csv('album_data', encoding='utf-8', index=False)