diff --git a/notebooks/spotify_rest_api_challenge.ipynb b/notebooks/spotify_rest_api_challenge.ipynb index 5e4f8f7..8779f2c 100644 --- a/notebooks/spotify_rest_api_challenge.ipynb +++ b/notebooks/spotify_rest_api_challenge.ipynb @@ -16,14 +16,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 72, "id": "17a49776", "metadata": {}, "outputs": [], "source": [ "# Imports\n", - "\n", - "\n" + "import pandas as pd \n", + "import requests" ] }, { @@ -38,21 +38,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 73, "id": "7b5d2e52", "metadata": {}, "outputs": [], "source": [ "# Generate token with a POST request\n", "\n", - "client_id = # CLIENT ID\n", - "client_secret = # CLIENT SECRET\n", + "client_id = '7da79d3bf1aa4d29a905648ce189281c'# CLIENT ID\n", + "client_secret = 'f697728d239b4bafa24dfc57f9d5bebe'# CLIENT SECRET\n", "auth_url = 'https://accounts.spotify.com/api/token'" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 74, "id": "c7901d1e", "metadata": {}, "outputs": [], @@ -64,10 +64,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 75, "id": "262e7e18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'access_token': 'BQD-S1YtHAzDtNCyWqexzkl-Bjf7w1b6kXUffz-TBFP2Llwg1GzQO4TIugvF2eJSCmnrpyOtVd1n7FOsmPM-nzB5oTWRv8fFNBWOqJl-IHG_nqYI6Lc',\n", + " 'token_type': 'Bearer',\n", + " 'expires_in': 3600}" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "access_token = auth_response['access_token']\n", "auth_response" @@ -85,17 +98,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 76, "id": "62e6d4fb", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'Authorization': 'Bearer BQD-S1YtHAzDtNCyWqexzkl-Bjf7w1b6kXUffz-TBFP2Llwg1GzQO4TIugvF2eJSCmnrpyOtVd1n7FOsmPM-nzB5oTWRv8fFNBWOqJl-IHG_nqYI6Lc'}" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Base end-point construction\n", "\n", "base_url = 'https://api.spotify.com/v1/'\n", "resource = 'artists/'\n", "\n", - "header_info = {'Authorization': 'Bearer {token}'.format(token=access_token)}" + "header_info = {'Authorization': 'Bearer {token}'.format(token=access_token)}\n", + "header_info" ] }, { @@ -143,27 +168,2252 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 77, "id": "04f85940", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb'" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Here you can complete your endpoint URI\n", - "\n", - "full_endpoint = \n", + "artist_id = '4Z8W4fKeB5YxbusRsdQVPb'\n", + "method = 'artists/'\n", + "full_endpoint = base_url + method + artist_id\n", "full_endpoint" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 78, "id": "50ec3959", "metadata": {}, "outputs": [], "source": [ "# Start building your playlist!!!\n", + "response = requests.get(full_endpoint, headers=header_info).json()" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "af6a65f7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'external_urls': {'spotify': 'https://open.spotify.com/artist/4Z8W4fKeB5YxbusRsdQVPb'},\n", + " 'followers': {'href': None, 'total': 8884416},\n", + " 'genres': ['alternative rock',\n", + " 'art rock',\n", + " 'melancholia',\n", + " 'oxford indie',\n", + " 'permanent wave',\n", + " 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb',\n", + " 'id': '4Z8W4fKeB5YxbusRsdQVPb',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eba03696716c9ee605006047fd',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174a03696716c9ee605006047fd',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178a03696716c9ee605006047fd',\n", + " 'width': 160}],\n", + " 'name': 'Radiohead',\n", + " 'popularity': 78,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4Z8W4fKeB5YxbusRsdQVPb'}" + ] + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "id": "e130c42f", + "metadata": {}, + "outputs": [], + "source": [ + "dict_artist = dict((key, [response[key]])for key in ['id', 'name', 'genres', 'popularity', 'followers']if key in response)" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "5bb6a406", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'id': ['4Z8W4fKeB5YxbusRsdQVPb'],\n", + " 'name': ['Radiohead'],\n", + " 'genres': [['alternative rock',\n", + " 'art rock',\n", + " 'melancholia',\n", + " 'oxford indie',\n", + " 'permanent wave',\n", + " 'rock']],\n", + " 'popularity': [78],\n", + " 'followers': [{'href': None, 'total': 8884416}]}" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dict_artist" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "id": "940039fa", + "metadata": {}, + "outputs": [], + "source": [ + "df_artist = pd.DataFrame(dict_artist)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "id": "816670c1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idnamegenrespopularityfollowers
04Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
\n", + "
" + ], + "text/plain": [ + " id name \\\n", + "0 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "\n", + " genres popularity \\\n", + "0 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "\n", + " followers \n", + "0 {'href': None, 'total': 8884416} " + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_artist" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "id": "0753d02f", + "metadata": {}, + "outputs": [], + "source": [ + "df_artist = df_artist.rename(columns={'id': 'artist_id',\n", + " })" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "id": "bcd01ef0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
artist_idnamegenrespopularityfollowers
04Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
\n", + "
" + ], + "text/plain": [ + " artist_id name \\\n", + "0 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "\n", + " genres popularity \\\n", + "0 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "\n", + " followers \n", + "0 {'href': None, 'total': 8884416} " + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_artist" + ] + }, + { + "cell_type": "markdown", + "id": "12958f21", + "metadata": {}, + "source": [ + "# Let's get the related artists info" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "id": "6e77944a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb/related-artists'" + ] + }, + "execution_count": 86, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parameters = '/related-artists'\n", + "artist_id = '4Z8W4fKeB5YxbusRsdQVPb'\n", "\n", - "\n" + "url = base_url + resource + artist_id + parameters\n", + "\n", + "url" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "id": "ed0ba73e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/4CvTDPKA6W06DRfBnZKrau'},\n", + " 'followers': {'href': None, 'total': 985116},\n", + " 'genres': ['alternative rock',\n", + " 'art pop',\n", + " 'art rock',\n", + " 'electronica',\n", + " 'glitch pop',\n", + " 'indie rock',\n", + " 'oxford indie'],\n", + " 'href': 'https://api.spotify.com/v1/artists/4CvTDPKA6W06DRfBnZKrau',\n", + " 'id': '4CvTDPKA6W06DRfBnZKrau',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb3153f6fe26063cfcbfc57677',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051743153f6fe26063cfcbfc57677',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1783153f6fe26063cfcbfc57677',\n", + " 'width': 160}],\n", + " 'name': 'Thom Yorke',\n", + " 'popularity': 54,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:4CvTDPKA6W06DRfBnZKrau'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6zvul52xwTWzilBZl6BUbT'},\n", + " 'followers': {'href': None, 'total': 2694003},\n", + " 'genres': ['alternative rock', 'boston rock', 'permanent wave', 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/6zvul52xwTWzilBZl6BUbT',\n", + " 'id': '6zvul52xwTWzilBZl6BUbT',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebd0456128dd330d18e18b4715',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174d0456128dd330d18e18b4715',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178d0456128dd330d18e18b4715',\n", + " 'width': 160}],\n", + " 'name': 'Pixies',\n", + " 'popularity': 68,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6zvul52xwTWzilBZl6BUbT'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7MhMgCo0Bl0Kukl93PZbYS'},\n", + " 'followers': {'href': None, 'total': 3099793},\n", + " 'genres': ['alternative rock',\n", + " 'britpop',\n", + " 'madchester',\n", + " 'permanent wave',\n", + " 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7MhMgCo0Bl0Kukl93PZbYS',\n", + " 'id': '7MhMgCo0Bl0Kukl93PZbYS',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb00620d736644d2359ce99430',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000517400620d736644d2359ce99430',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f17800620d736644d2359ce99430',\n", + " 'width': 160}],\n", + " 'name': 'Blur',\n", + " 'popularity': 67,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7MhMgCo0Bl0Kukl93PZbYS'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3yY2gUcIsjMr8hjo51PoJ8'},\n", + " 'followers': {'href': None, 'total': 4647089},\n", + " 'genres': ['madchester',\n", + " 'new wave',\n", + " 'permanent wave',\n", + " 'rock',\n", + " 'uk post-punk'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3yY2gUcIsjMr8hjo51PoJ8',\n", + " 'id': '3yY2gUcIsjMr8hjo51PoJ8',\n", + " 'images': [{'height': 1516,\n", + " 'url': 'https://i.scdn.co/image/481b980af463122013e4578c08fb8c5cbfaed1e9',\n", + " 'width': 1000},\n", + " {'height': 970,\n", + " 'url': 'https://i.scdn.co/image/4bf08a9e6eea088b20d4092d1322bbd3f39ff9af',\n", + " 'width': 640},\n", + " {'height': 303,\n", + " 'url': 'https://i.scdn.co/image/bd4c7f5ff2c5c4385604e60c71eac1dd498ddbd9',\n", + " 'width': 200},\n", + " {'height': 97,\n", + " 'url': 'https://i.scdn.co/image/d3a2542f2811b5b01ee3483ec7c193f72a882ea1',\n", + " 'width': 64}],\n", + " 'name': 'The Smiths',\n", + " 'popularity': 74,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3yY2gUcIsjMr8hjo51PoJ8'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6liAMWkVf5LH7YR9yfFy1Y'},\n", + " 'followers': {'href': None, 'total': 1851714},\n", + " 'genres': ['alternative rock',\n", + " 'art pop',\n", + " 'dark pop',\n", + " 'electronica',\n", + " 'laboratorio',\n", + " 'trip hop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/6liAMWkVf5LH7YR9yfFy1Y',\n", + " 'id': '6liAMWkVf5LH7YR9yfFy1Y',\n", + " 'images': [{'height': 680,\n", + " 'url': 'https://i.scdn.co/image/05d3721739aee511a898081ab140daa7890a0120',\n", + " 'width': 1000},\n", + " {'height': 435,\n", + " 'url': 'https://i.scdn.co/image/27802710b01453435de93d71bab2c9988a841ace',\n", + " 'width': 640},\n", + " {'height': 136,\n", + " 'url': 'https://i.scdn.co/image/333ac38e3c8ab5fcdc238cc46535a4abb802eccc',\n", + " 'width': 200},\n", + " {'height': 44,\n", + " 'url': 'https://i.scdn.co/image/10052054c06626f6a900e687b20886e462f75568',\n", + " 'width': 64}],\n", + " 'name': 'Portishead',\n", + " 'popularity': 59,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6liAMWkVf5LH7YR9yfFy1Y'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/432R46LaYsJZV2Gmc4jUV5'},\n", + " 'followers': {'href': None, 'total': 2248108},\n", + " 'genres': ['alternative rock',\n", + " 'art rock',\n", + " 'indie rock',\n", + " 'madchester',\n", + " 'new wave',\n", + " 'post-punk',\n", + " 'punk',\n", + " 'rock',\n", + " 'uk post-punk'],\n", + " 'href': 'https://api.spotify.com/v1/artists/432R46LaYsJZV2Gmc4jUV5',\n", + " 'id': '432R46LaYsJZV2Gmc4jUV5',\n", + " 'images': [{'height': 658,\n", + " 'url': 'https://i.scdn.co/image/5eeddd733170399db794d2c430a8d2cde7ae1425',\n", + " 'width': 1000},\n", + " {'height': 421,\n", + " 'url': 'https://i.scdn.co/image/d3c6bcb07a5ecddf86e791fa901bf3792fe6e6c7',\n", + " 'width': 640},\n", + " {'height': 132,\n", + " 'url': 'https://i.scdn.co/image/d384ebd3d3fda0ad219fed6b9014a59e65fbb385',\n", + " 'width': 200},\n", + " {'height': 42,\n", + " 'url': 'https://i.scdn.co/image/1b5195d5e9b5aac07fb0c801deb1926138222036',\n", + " 'width': 64}],\n", + " 'name': 'Joy Division',\n", + " 'popularity': 61,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:432R46LaYsJZV2Gmc4jUV5'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7bu3H8JO7d0UbMoVzbo70s'},\n", + " 'followers': {'href': None, 'total': 4886284},\n", + " 'genres': ['new wave', 'permanent wave', 'rock', 'uk post-punk'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7bu3H8JO7d0UbMoVzbo70s',\n", + " 'id': '7bu3H8JO7d0UbMoVzbo70s',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/7ca743e822b80133971ccf5c70fcbd77a4f4f508',\n", + " 'width': 640},\n", + " {'height': 200,\n", + " 'url': 'https://i.scdn.co/image/2cb2e14783685fd3d27006891aaaa35fc53cd82d',\n", + " 'width': 200},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/9e1ed6613ac0ef103fbfca3c11ff35fec8d9c6b1',\n", + " 'width': 64}],\n", + " 'name': 'The Cure',\n", + " 'popularity': 73,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7bu3H8JO7d0UbMoVzbo70s'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/0epOFNiUfyON9EYx7Tpr6V'},\n", + " 'followers': {'href': None, 'total': 5260718},\n", + " 'genres': ['alternative rock',\n", + " 'garage rock',\n", + " 'modern rock',\n", + " 'permanent wave',\n", + " 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/0epOFNiUfyON9EYx7Tpr6V',\n", + " 'id': '0epOFNiUfyON9EYx7Tpr6V',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebcaea403b29f6a09260b6a18a',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174caea403b29f6a09260b6a18a',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178caea403b29f6a09260b6a18a',\n", + " 'width': 160}],\n", + " 'name': 'The Strokes',\n", + " 'popularity': 73,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:0epOFNiUfyON9EYx7Tpr6V'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/40Yq4vzPs9VNUrIBG5Jr2i'},\n", + " 'followers': {'href': None, 'total': 4762503},\n", + " 'genres': ['alternative metal',\n", + " 'alternative rock',\n", + " 'grunge',\n", + " 'permanent wave',\n", + " 'rock',\n", + " 'spacegrunge'],\n", + " 'href': 'https://api.spotify.com/v1/artists/40Yq4vzPs9VNUrIBG5Jr2i',\n", + " 'id': '40Yq4vzPs9VNUrIBG5Jr2i',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebbd85f631779e65b01349d747',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174bd85f631779e65b01349d747',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178bd85f631779e65b01349d747',\n", + " 'width': 160}],\n", + " 'name': 'The Smashing Pumpkins',\n", + " 'popularity': 70,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:40Yq4vzPs9VNUrIBG5Jr2i'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/5UqTO8smerMvxHYA5xsXb6'},\n", + " 'followers': {'href': None, 'total': 1072692},\n", + " 'genres': ['alternative rock',\n", + " 'indie rock',\n", + " 'noise pop',\n", + " 'noise rock',\n", + " 'rock',\n", + " 'shoegaze'],\n", + " 'href': 'https://api.spotify.com/v1/artists/5UqTO8smerMvxHYA5xsXb6',\n", + " 'id': '5UqTO8smerMvxHYA5xsXb6',\n", + " 'images': [{'height': 987,\n", + " 'url': 'https://i.scdn.co/image/af335c11a73e9311516bb28800be58311410d1be',\n", + " 'width': 1000},\n", + " {'height': 632,\n", + " 'url': 'https://i.scdn.co/image/a6f14050fe0b0e188d23298efffd3ff06511e99c',\n", + " 'width': 640},\n", + " {'height': 197,\n", + " 'url': 'https://i.scdn.co/image/976d63d12b1c9ea37edbef69ad5439ab79a59889',\n", + " 'width': 200},\n", + " {'height': 63,\n", + " 'url': 'https://i.scdn.co/image/4efa809bcbed4385812febceb5fe665f6dde361e',\n", + " 'width': 64}],\n", + " 'name': 'Sonic Youth',\n", + " 'popularity': 55,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:5UqTO8smerMvxHYA5xsXb6'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3G3Gdm0ZRAOxLrbyjfhii5'},\n", + " 'followers': {'href': None, 'total': 811456},\n", + " 'genres': ['alternative rock', 'dream pop', 'noise pop', 'shoegaze'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3G3Gdm0ZRAOxLrbyjfhii5',\n", + " 'id': '3G3Gdm0ZRAOxLrbyjfhii5',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb21c79e4e6e1af6af9b94d3a0',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000517421c79e4e6e1af6af9b94d3a0',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f17821c79e4e6e1af6af9b94d3a0',\n", + " 'width': 160}],\n", + " 'name': 'my bloody valentine',\n", + " 'popularity': 54,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3G3Gdm0ZRAOxLrbyjfhii5'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/72X6FHxaShda0XeQw3vbeF'},\n", + " 'followers': {'href': None, 'total': 857825},\n", + " 'genres': ['alternative rock',\n", + " 'dream pop',\n", + " 'nu gaze',\n", + " 'reading indie',\n", + " 'shoegaze'],\n", + " 'href': 'https://api.spotify.com/v1/artists/72X6FHxaShda0XeQw3vbeF',\n", + " 'id': '72X6FHxaShda0XeQw3vbeF',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb653481f50df3c11791d6132a',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174653481f50df3c11791d6132a',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178653481f50df3c11791d6132a',\n", + " 'width': 160}],\n", + " 'name': 'Slowdive',\n", + " 'popularity': 60,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:72X6FHxaShda0XeQw3vbeF'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/7w29UYBi0qsHi5RTcv3lmA'},\n", + " 'followers': {'href': None, 'total': 1917156},\n", + " 'genres': ['alternative rock',\n", + " 'art pop',\n", + " 'electronica',\n", + " 'experimental pop',\n", + " 'experimental vocal',\n", + " 'icelandic experimental',\n", + " 'icelandic pop',\n", + " 'icelandic singer-songwriter',\n", + " 'metropopolis',\n", + " 'permanent wave',\n", + " 'trip hop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/7w29UYBi0qsHi5RTcv3lmA',\n", + " 'id': '7w29UYBi0qsHi5RTcv3lmA',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebaeb5c04fdd8ec6273850d207',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174aeb5c04fdd8ec6273850d207',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178aeb5c04fdd8ec6273850d207',\n", + " 'width': 160}],\n", + " 'name': 'Björk',\n", + " 'popularity': 59,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:7w29UYBi0qsHi5RTcv3lmA'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3nnQpaTvKb5jCQabZefACI'},\n", + " 'followers': {'href': None, 'total': 1155378},\n", + " 'genres': ['melancholia', 'permanent wave', 'singer-songwriter'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3nnQpaTvKb5jCQabZefACI',\n", + " 'id': '3nnQpaTvKb5jCQabZefACI',\n", + " 'images': [{'height': 1520,\n", + " 'url': 'https://i.scdn.co/image/67779606c7f151618a28f62b1d24fb514d39dacf',\n", + " 'width': 1000},\n", + " {'height': 973,\n", + " 'url': 'https://i.scdn.co/image/248e8ddbf1be229fd0c31722fb0a01b31b01f474',\n", + " 'width': 640},\n", + " {'height': 304,\n", + " 'url': 'https://i.scdn.co/image/8822f816dea6ea25c70e942763c9812c6271e516',\n", + " 'width': 200},\n", + " {'height': 97,\n", + " 'url': 'https://i.scdn.co/image/2a93d455e8981b0e1f6f1918b934c454c1243b20',\n", + " 'width': 64}],\n", + " 'name': 'Jeff Buckley',\n", + " 'popularity': 61,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3nnQpaTvKb5jCQabZefACI'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3WaJSfKnzc65VDgmj2zU8B'},\n", + " 'followers': {'href': None, 'total': 1616230},\n", + " 'genres': ['alternative dance',\n", + " 'alternative rock',\n", + " 'indie rock',\n", + " 'indietronica',\n", + " 'modern rock',\n", + " 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3WaJSfKnzc65VDgmj2zU8B',\n", + " 'id': '3WaJSfKnzc65VDgmj2zU8B',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5ebc31f8e7aad462874455cf070',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174c31f8e7aad462874455cf070',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178c31f8e7aad462874455cf070',\n", + " 'width': 160}],\n", + " 'name': 'Interpol',\n", + " 'popularity': 61,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3WaJSfKnzc65VDgmj2zU8B'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6Ghvu1VvMGScGpOUJBAHNH'},\n", + " 'followers': {'href': None, 'total': 4543728},\n", + " 'genres': ['alternative metal',\n", + " 'nu metal',\n", + " 'rap metal',\n", + " 'rock',\n", + " 'sacramento indie'],\n", + " 'href': 'https://api.spotify.com/v1/artists/6Ghvu1VvMGScGpOUJBAHNH',\n", + " 'id': '6Ghvu1VvMGScGpOUJBAHNH',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb4b2da0b72cab26ac518f1f0d',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab676161000051744b2da0b72cab26ac518f1f0d',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f1784b2da0b72cab26ac518f1f0d',\n", + " 'width': 160}],\n", + " 'name': 'Deftones',\n", + " 'popularity': 75,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6Ghvu1VvMGScGpOUJBAHNH'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/3kjuyTCjPG1WMFCiyc5IuB'},\n", + " 'followers': {'href': None, 'total': 2233533},\n", + " 'genres': ['alternative rock',\n", + " 'baroque pop',\n", + " 'canadian indie',\n", + " 'chamber pop',\n", + " 'indie rock',\n", + " 'indietronica',\n", + " 'modern rock',\n", + " 'permanent wave',\n", + " 'quebec indie',\n", + " 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/3kjuyTCjPG1WMFCiyc5IuB',\n", + " 'id': '3kjuyTCjPG1WMFCiyc5IuB',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eba044e15eee771205956dcbf8',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174a044e15eee771205956dcbf8',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178a044e15eee771205956dcbf8',\n", + " 'width': 160}],\n", + " 'name': 'Arcade Fire',\n", + " 'popularity': 62,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:3kjuyTCjPG1WMFCiyc5IuB'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/1nJvji2KIlWSseXRSlNYsC'},\n", + " 'followers': {'href': None, 'total': 1800640},\n", + " 'genres': ['alternative rock',\n", + " 'melancholia',\n", + " 'permanent wave',\n", + " 'protopunk',\n", + " 'rock'],\n", + " 'href': 'https://api.spotify.com/v1/artists/1nJvji2KIlWSseXRSlNYsC',\n", + " 'id': '1nJvji2KIlWSseXRSlNYsC',\n", + " 'images': [{'height': 1236,\n", + " 'url': 'https://i.scdn.co/image/d69c2cf10323bf08443c7d122f3a1824a760ab57',\n", + " 'width': 1000},\n", + " {'height': 791,\n", + " 'url': 'https://i.scdn.co/image/24e7531935f88f55744cc8c9ed2528f466cba276',\n", + " 'width': 640},\n", + " {'height': 247,\n", + " 'url': 'https://i.scdn.co/image/fedcb6f64de6571e2c208a21fc16b9e05e38cf2f',\n", + " 'width': 200},\n", + " {'height': 79,\n", + " 'url': 'https://i.scdn.co/image/0fda1f46337398e35d5c7c672ddc77beb68a8f93',\n", + " 'width': 64}],\n", + " 'name': 'The Velvet Underground',\n", + " 'popularity': 60,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:1nJvji2KIlWSseXRSlNYsC'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/6FXMGgJwohJLUSr5nVlf9X'},\n", + " 'followers': {'href': None, 'total': 2076951},\n", + " 'genres': ['downtempo', 'electronica', 'trip hop'],\n", + " 'href': 'https://api.spotify.com/v1/artists/6FXMGgJwohJLUSr5nVlf9X',\n", + " 'id': '6FXMGgJwohJLUSr5nVlf9X',\n", + " 'images': [{'height': 1335,\n", + " 'url': 'https://i.scdn.co/image/c8bbeedb05f38ae5cb982a7daf4bf7129cca892c',\n", + " 'width': 1000},\n", + " {'height': 855,\n", + " 'url': 'https://i.scdn.co/image/52c2a824e84f4e8adf0b12418f9f8306b4b5b77a',\n", + " 'width': 640},\n", + " {'height': 267,\n", + " 'url': 'https://i.scdn.co/image/0d6b7677f8291c5158bdace8a6e027880c527c2a',\n", + " 'width': 200},\n", + " {'height': 85,\n", + " 'url': 'https://i.scdn.co/image/c055290bb6e97a589d8ca659cd452a8e9831c2c4',\n", + " 'width': 64}],\n", + " 'name': 'Massive Attack',\n", + " 'popularity': 61,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:6FXMGgJwohJLUSr5nVlf9X'},\n", + " {'external_urls': {'spotify': 'https://open.spotify.com/artist/2ApaG60P4r0yhBoDCGD8YG'},\n", + " 'followers': {'href': None, 'total': 1000573},\n", + " 'genres': ['alternative rock',\n", + " 'indie rock',\n", + " 'melancholia',\n", + " 'singer-songwriter'],\n", + " 'href': 'https://api.spotify.com/v1/artists/2ApaG60P4r0yhBoDCGD8YG',\n", + " 'id': '2ApaG60P4r0yhBoDCGD8YG',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000e5eb079739b801ab3f105866b76f',\n", + " 'width': 640},\n", + " {'height': 320,\n", + " 'url': 'https://i.scdn.co/image/ab67616100005174079739b801ab3f105866b76f',\n", + " 'width': 320},\n", + " {'height': 160,\n", + " 'url': 'https://i.scdn.co/image/ab6761610000f178079739b801ab3f105866b76f',\n", + " 'width': 160}],\n", + " 'name': 'Elliott Smith',\n", + " 'popularity': 62,\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2ApaG60P4r0yhBoDCGD8YG'}]}" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response = requests.get(url, headers=header_info).json()\n", + "response" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "id": "3e74fa81", + "metadata": {}, + "outputs": [], + "source": [ + "df_related_artists = pd.DataFrame(response['artists'])[['id', 'name', 'genres', 'popularity','followers']]" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "id": "9213fd43", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idnamegenrespopularityfollowers
04CvTDPKA6W06DRfBnZKrauThom Yorke[alternative rock, art pop, art rock, electron...54{'href': None, 'total': 985116}
16zvul52xwTWzilBZl6BUbTPixies[alternative rock, boston rock, permanent wave...68{'href': None, 'total': 2694003}
27MhMgCo0Bl0Kukl93PZbYSBlur[alternative rock, britpop, madchester, perman...67{'href': None, 'total': 3099793}
33yY2gUcIsjMr8hjo51PoJ8The Smiths[madchester, new wave, permanent wave, rock, u...74{'href': None, 'total': 4647089}
46liAMWkVf5LH7YR9yfFy1YPortishead[alternative rock, art pop, dark pop, electron...59{'href': None, 'total': 1851714}
5432R46LaYsJZV2Gmc4jUV5Joy Division[alternative rock, art rock, indie rock, madch...61{'href': None, 'total': 2248108}
67bu3H8JO7d0UbMoVzbo70sThe Cure[new wave, permanent wave, rock, uk post-punk]73{'href': None, 'total': 4886284}
70epOFNiUfyON9EYx7Tpr6VThe Strokes[alternative rock, garage rock, modern rock, p...73{'href': None, 'total': 5260718}
840Yq4vzPs9VNUrIBG5Jr2iThe Smashing Pumpkins[alternative metal, alternative rock, grunge, ...70{'href': None, 'total': 4762503}
95UqTO8smerMvxHYA5xsXb6Sonic Youth[alternative rock, indie rock, noise pop, nois...55{'href': None, 'total': 1072692}
103G3Gdm0ZRAOxLrbyjfhii5my bloody valentine[alternative rock, dream pop, noise pop, shoeg...54{'href': None, 'total': 811456}
1172X6FHxaShda0XeQw3vbeFSlowdive[alternative rock, dream pop, nu gaze, reading...60{'href': None, 'total': 857825}
127w29UYBi0qsHi5RTcv3lmABjörk[alternative rock, art pop, electronica, exper...59{'href': None, 'total': 1917156}
133nnQpaTvKb5jCQabZefACIJeff Buckley[melancholia, permanent wave, singer-songwriter]61{'href': None, 'total': 1155378}
143WaJSfKnzc65VDgmj2zU8BInterpol[alternative dance, alternative rock, indie ro...61{'href': None, 'total': 1616230}
156Ghvu1VvMGScGpOUJBAHNHDeftones[alternative metal, nu metal, rap metal, rock,...75{'href': None, 'total': 4543728}
163kjuyTCjPG1WMFCiyc5IuBArcade Fire[alternative rock, baroque pop, canadian indie...62{'href': None, 'total': 2233533}
171nJvji2KIlWSseXRSlNYsCThe Velvet Underground[alternative rock, melancholia, permanent wave...60{'href': None, 'total': 1800640}
186FXMGgJwohJLUSr5nVlf9XMassive Attack[downtempo, electronica, trip hop]61{'href': None, 'total': 2076951}
192ApaG60P4r0yhBoDCGD8YGElliott Smith[alternative rock, indie rock, melancholia, si...62{'href': None, 'total': 1000573}
\n", + "
" + ], + "text/plain": [ + " id name \\\n", + "0 4CvTDPKA6W06DRfBnZKrau Thom Yorke \n", + "1 6zvul52xwTWzilBZl6BUbT Pixies \n", + "2 7MhMgCo0Bl0Kukl93PZbYS Blur \n", + "3 3yY2gUcIsjMr8hjo51PoJ8 The Smiths \n", + "4 6liAMWkVf5LH7YR9yfFy1Y Portishead \n", + "5 432R46LaYsJZV2Gmc4jUV5 Joy Division \n", + "6 7bu3H8JO7d0UbMoVzbo70s The Cure \n", + "7 0epOFNiUfyON9EYx7Tpr6V The Strokes \n", + "8 40Yq4vzPs9VNUrIBG5Jr2i The Smashing Pumpkins \n", + "9 5UqTO8smerMvxHYA5xsXb6 Sonic Youth \n", + "10 3G3Gdm0ZRAOxLrbyjfhii5 my bloody valentine \n", + "11 72X6FHxaShda0XeQw3vbeF Slowdive \n", + "12 7w29UYBi0qsHi5RTcv3lmA Björk \n", + "13 3nnQpaTvKb5jCQabZefACI Jeff Buckley \n", + "14 3WaJSfKnzc65VDgmj2zU8B Interpol \n", + "15 6Ghvu1VvMGScGpOUJBAHNH Deftones \n", + "16 3kjuyTCjPG1WMFCiyc5IuB Arcade Fire \n", + "17 1nJvji2KIlWSseXRSlNYsC The Velvet Underground \n", + "18 6FXMGgJwohJLUSr5nVlf9X Massive Attack \n", + "19 2ApaG60P4r0yhBoDCGD8YG Elliott Smith \n", + "\n", + " genres popularity \\\n", + "0 [alternative rock, art pop, art rock, electron... 54 \n", + "1 [alternative rock, boston rock, permanent wave... 68 \n", + "2 [alternative rock, britpop, madchester, perman... 67 \n", + "3 [madchester, new wave, permanent wave, rock, u... 74 \n", + "4 [alternative rock, art pop, dark pop, electron... 59 \n", + "5 [alternative rock, art rock, indie rock, madch... 61 \n", + "6 [new wave, permanent wave, rock, uk post-punk] 73 \n", + "7 [alternative rock, garage rock, modern rock, p... 73 \n", + "8 [alternative metal, alternative rock, grunge, ... 70 \n", + "9 [alternative rock, indie rock, noise pop, nois... 55 \n", + "10 [alternative rock, dream pop, noise pop, shoeg... 54 \n", + "11 [alternative rock, dream pop, nu gaze, reading... 60 \n", + "12 [alternative rock, art pop, electronica, exper... 59 \n", + "13 [melancholia, permanent wave, singer-songwriter] 61 \n", + "14 [alternative dance, alternative rock, indie ro... 61 \n", + "15 [alternative metal, nu metal, rap metal, rock,... 75 \n", + "16 [alternative rock, baroque pop, canadian indie... 62 \n", + "17 [alternative rock, melancholia, permanent wave... 60 \n", + "18 [downtempo, electronica, trip hop] 61 \n", + "19 [alternative rock, indie rock, melancholia, si... 62 \n", + "\n", + " followers \n", + "0 {'href': None, 'total': 985116} \n", + "1 {'href': None, 'total': 2694003} \n", + "2 {'href': None, 'total': 3099793} \n", + "3 {'href': None, 'total': 4647089} \n", + "4 {'href': None, 'total': 1851714} \n", + "5 {'href': None, 'total': 2248108} \n", + "6 {'href': None, 'total': 4886284} \n", + "7 {'href': None, 'total': 5260718} \n", + "8 {'href': None, 'total': 4762503} \n", + "9 {'href': None, 'total': 1072692} \n", + "10 {'href': None, 'total': 811456} \n", + "11 {'href': None, 'total': 857825} \n", + "12 {'href': None, 'total': 1917156} \n", + "13 {'href': None, 'total': 1155378} \n", + "14 {'href': None, 'total': 1616230} \n", + "15 {'href': None, 'total': 4543728} \n", + "16 {'href': None, 'total': 2233533} \n", + "17 {'href': None, 'total': 1800640} \n", + "18 {'href': None, 'total': 2076951} \n", + "19 {'href': None, 'total': 1000573} " + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_related_artists" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "id": "e6a32e52", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
related_idrelated_namerelated_genresrelated_popularityrelated_followers
04CvTDPKA6W06DRfBnZKrauThom Yorke[alternative rock, art pop, art rock, electron...54{'href': None, 'total': 985116}
16zvul52xwTWzilBZl6BUbTPixies[alternative rock, boston rock, permanent wave...68{'href': None, 'total': 2694003}
27MhMgCo0Bl0Kukl93PZbYSBlur[alternative rock, britpop, madchester, perman...67{'href': None, 'total': 3099793}
33yY2gUcIsjMr8hjo51PoJ8The Smiths[madchester, new wave, permanent wave, rock, u...74{'href': None, 'total': 4647089}
46liAMWkVf5LH7YR9yfFy1YPortishead[alternative rock, art pop, dark pop, electron...59{'href': None, 'total': 1851714}
5432R46LaYsJZV2Gmc4jUV5Joy Division[alternative rock, art rock, indie rock, madch...61{'href': None, 'total': 2248108}
67bu3H8JO7d0UbMoVzbo70sThe Cure[new wave, permanent wave, rock, uk post-punk]73{'href': None, 'total': 4886284}
70epOFNiUfyON9EYx7Tpr6VThe Strokes[alternative rock, garage rock, modern rock, p...73{'href': None, 'total': 5260718}
840Yq4vzPs9VNUrIBG5Jr2iThe Smashing Pumpkins[alternative metal, alternative rock, grunge, ...70{'href': None, 'total': 4762503}
95UqTO8smerMvxHYA5xsXb6Sonic Youth[alternative rock, indie rock, noise pop, nois...55{'href': None, 'total': 1072692}
103G3Gdm0ZRAOxLrbyjfhii5my bloody valentine[alternative rock, dream pop, noise pop, shoeg...54{'href': None, 'total': 811456}
1172X6FHxaShda0XeQw3vbeFSlowdive[alternative rock, dream pop, nu gaze, reading...60{'href': None, 'total': 857825}
127w29UYBi0qsHi5RTcv3lmABjörk[alternative rock, art pop, electronica, exper...59{'href': None, 'total': 1917156}
133nnQpaTvKb5jCQabZefACIJeff Buckley[melancholia, permanent wave, singer-songwriter]61{'href': None, 'total': 1155378}
143WaJSfKnzc65VDgmj2zU8BInterpol[alternative dance, alternative rock, indie ro...61{'href': None, 'total': 1616230}
156Ghvu1VvMGScGpOUJBAHNHDeftones[alternative metal, nu metal, rap metal, rock,...75{'href': None, 'total': 4543728}
163kjuyTCjPG1WMFCiyc5IuBArcade Fire[alternative rock, baroque pop, canadian indie...62{'href': None, 'total': 2233533}
171nJvji2KIlWSseXRSlNYsCThe Velvet Underground[alternative rock, melancholia, permanent wave...60{'href': None, 'total': 1800640}
186FXMGgJwohJLUSr5nVlf9XMassive Attack[downtempo, electronica, trip hop]61{'href': None, 'total': 2076951}
192ApaG60P4r0yhBoDCGD8YGElliott Smith[alternative rock, indie rock, melancholia, si...62{'href': None, 'total': 1000573}
\n", + "
" + ], + "text/plain": [ + " related_id related_name \\\n", + "0 4CvTDPKA6W06DRfBnZKrau Thom Yorke \n", + "1 6zvul52xwTWzilBZl6BUbT Pixies \n", + "2 7MhMgCo0Bl0Kukl93PZbYS Blur \n", + "3 3yY2gUcIsjMr8hjo51PoJ8 The Smiths \n", + "4 6liAMWkVf5LH7YR9yfFy1Y Portishead \n", + "5 432R46LaYsJZV2Gmc4jUV5 Joy Division \n", + "6 7bu3H8JO7d0UbMoVzbo70s The Cure \n", + "7 0epOFNiUfyON9EYx7Tpr6V The Strokes \n", + "8 40Yq4vzPs9VNUrIBG5Jr2i The Smashing Pumpkins \n", + "9 5UqTO8smerMvxHYA5xsXb6 Sonic Youth \n", + "10 3G3Gdm0ZRAOxLrbyjfhii5 my bloody valentine \n", + "11 72X6FHxaShda0XeQw3vbeF Slowdive \n", + "12 7w29UYBi0qsHi5RTcv3lmA Björk \n", + "13 3nnQpaTvKb5jCQabZefACI Jeff Buckley \n", + "14 3WaJSfKnzc65VDgmj2zU8B Interpol \n", + "15 6Ghvu1VvMGScGpOUJBAHNH Deftones \n", + "16 3kjuyTCjPG1WMFCiyc5IuB Arcade Fire \n", + "17 1nJvji2KIlWSseXRSlNYsC The Velvet Underground \n", + "18 6FXMGgJwohJLUSr5nVlf9X Massive Attack \n", + "19 2ApaG60P4r0yhBoDCGD8YG Elliott Smith \n", + "\n", + " related_genres related_popularity \\\n", + "0 [alternative rock, art pop, art rock, electron... 54 \n", + "1 [alternative rock, boston rock, permanent wave... 68 \n", + "2 [alternative rock, britpop, madchester, perman... 67 \n", + "3 [madchester, new wave, permanent wave, rock, u... 74 \n", + "4 [alternative rock, art pop, dark pop, electron... 59 \n", + "5 [alternative rock, art rock, indie rock, madch... 61 \n", + "6 [new wave, permanent wave, rock, uk post-punk] 73 \n", + "7 [alternative rock, garage rock, modern rock, p... 73 \n", + "8 [alternative metal, alternative rock, grunge, ... 70 \n", + "9 [alternative rock, indie rock, noise pop, nois... 55 \n", + "10 [alternative rock, dream pop, noise pop, shoeg... 54 \n", + "11 [alternative rock, dream pop, nu gaze, reading... 60 \n", + "12 [alternative rock, art pop, electronica, exper... 59 \n", + "13 [melancholia, permanent wave, singer-songwriter] 61 \n", + "14 [alternative dance, alternative rock, indie ro... 61 \n", + "15 [alternative metal, nu metal, rap metal, rock,... 75 \n", + "16 [alternative rock, baroque pop, canadian indie... 62 \n", + "17 [alternative rock, melancholia, permanent wave... 60 \n", + "18 [downtempo, electronica, trip hop] 61 \n", + "19 [alternative rock, indie rock, melancholia, si... 62 \n", + "\n", + " related_followers \n", + "0 {'href': None, 'total': 985116} \n", + "1 {'href': None, 'total': 2694003} \n", + "2 {'href': None, 'total': 3099793} \n", + "3 {'href': None, 'total': 4647089} \n", + "4 {'href': None, 'total': 1851714} \n", + "5 {'href': None, 'total': 2248108} \n", + "6 {'href': None, 'total': 4886284} \n", + "7 {'href': None, 'total': 5260718} \n", + "8 {'href': None, 'total': 4762503} \n", + "9 {'href': None, 'total': 1072692} \n", + "10 {'href': None, 'total': 811456} \n", + "11 {'href': None, 'total': 857825} \n", + "12 {'href': None, 'total': 1917156} \n", + "13 {'href': None, 'total': 1155378} \n", + "14 {'href': None, 'total': 1616230} \n", + "15 {'href': None, 'total': 4543728} \n", + "16 {'href': None, 'total': 2233533} \n", + "17 {'href': None, 'total': 1800640} \n", + "18 {'href': None, 'total': 2076951} \n", + "19 {'href': None, 'total': 1000573} " + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#rename de columns\n", + "df_related_artists = df_related_artists.rename(columns={'id': 'related_id',\n", + " 'name': 'related_name',\n", + " 'genres': 'related_genres',\n", + " 'popularity': 'related_popularity',\n", + " 'followers': 'related_followers'\n", + " })\n", + "df_related_artists" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "id": "fac7fc99", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
related_idrelated_namerelated_genresrelated_popularityrelated_followersartist_id
04CvTDPKA6W06DRfBnZKrauThom Yorke[alternative rock, art pop, art rock, electron...54{'href': None, 'total': 985116}4Z8W4fKeB5YxbusRsdQVPb
16zvul52xwTWzilBZl6BUbTPixies[alternative rock, boston rock, permanent wave...68{'href': None, 'total': 2694003}4Z8W4fKeB5YxbusRsdQVPb
27MhMgCo0Bl0Kukl93PZbYSBlur[alternative rock, britpop, madchester, perman...67{'href': None, 'total': 3099793}4Z8W4fKeB5YxbusRsdQVPb
33yY2gUcIsjMr8hjo51PoJ8The Smiths[madchester, new wave, permanent wave, rock, u...74{'href': None, 'total': 4647089}4Z8W4fKeB5YxbusRsdQVPb
46liAMWkVf5LH7YR9yfFy1YPortishead[alternative rock, art pop, dark pop, electron...59{'href': None, 'total': 1851714}4Z8W4fKeB5YxbusRsdQVPb
5432R46LaYsJZV2Gmc4jUV5Joy Division[alternative rock, art rock, indie rock, madch...61{'href': None, 'total': 2248108}4Z8W4fKeB5YxbusRsdQVPb
67bu3H8JO7d0UbMoVzbo70sThe Cure[new wave, permanent wave, rock, uk post-punk]73{'href': None, 'total': 4886284}4Z8W4fKeB5YxbusRsdQVPb
70epOFNiUfyON9EYx7Tpr6VThe Strokes[alternative rock, garage rock, modern rock, p...73{'href': None, 'total': 5260718}4Z8W4fKeB5YxbusRsdQVPb
840Yq4vzPs9VNUrIBG5Jr2iThe Smashing Pumpkins[alternative metal, alternative rock, grunge, ...70{'href': None, 'total': 4762503}4Z8W4fKeB5YxbusRsdQVPb
95UqTO8smerMvxHYA5xsXb6Sonic Youth[alternative rock, indie rock, noise pop, nois...55{'href': None, 'total': 1072692}4Z8W4fKeB5YxbusRsdQVPb
103G3Gdm0ZRAOxLrbyjfhii5my bloody valentine[alternative rock, dream pop, noise pop, shoeg...54{'href': None, 'total': 811456}4Z8W4fKeB5YxbusRsdQVPb
1172X6FHxaShda0XeQw3vbeFSlowdive[alternative rock, dream pop, nu gaze, reading...60{'href': None, 'total': 857825}4Z8W4fKeB5YxbusRsdQVPb
127w29UYBi0qsHi5RTcv3lmABjörk[alternative rock, art pop, electronica, exper...59{'href': None, 'total': 1917156}4Z8W4fKeB5YxbusRsdQVPb
133nnQpaTvKb5jCQabZefACIJeff Buckley[melancholia, permanent wave, singer-songwriter]61{'href': None, 'total': 1155378}4Z8W4fKeB5YxbusRsdQVPb
143WaJSfKnzc65VDgmj2zU8BInterpol[alternative dance, alternative rock, indie ro...61{'href': None, 'total': 1616230}4Z8W4fKeB5YxbusRsdQVPb
156Ghvu1VvMGScGpOUJBAHNHDeftones[alternative metal, nu metal, rap metal, rock,...75{'href': None, 'total': 4543728}4Z8W4fKeB5YxbusRsdQVPb
163kjuyTCjPG1WMFCiyc5IuBArcade Fire[alternative rock, baroque pop, canadian indie...62{'href': None, 'total': 2233533}4Z8W4fKeB5YxbusRsdQVPb
171nJvji2KIlWSseXRSlNYsCThe Velvet Underground[alternative rock, melancholia, permanent wave...60{'href': None, 'total': 1800640}4Z8W4fKeB5YxbusRsdQVPb
186FXMGgJwohJLUSr5nVlf9XMassive Attack[downtempo, electronica, trip hop]61{'href': None, 'total': 2076951}4Z8W4fKeB5YxbusRsdQVPb
192ApaG60P4r0yhBoDCGD8YGElliott Smith[alternative rock, indie rock, melancholia, si...62{'href': None, 'total': 1000573}4Z8W4fKeB5YxbusRsdQVPb
\n", + "
" + ], + "text/plain": [ + " related_id related_name \\\n", + "0 4CvTDPKA6W06DRfBnZKrau Thom Yorke \n", + "1 6zvul52xwTWzilBZl6BUbT Pixies \n", + "2 7MhMgCo0Bl0Kukl93PZbYS Blur \n", + "3 3yY2gUcIsjMr8hjo51PoJ8 The Smiths \n", + "4 6liAMWkVf5LH7YR9yfFy1Y Portishead \n", + "5 432R46LaYsJZV2Gmc4jUV5 Joy Division \n", + "6 7bu3H8JO7d0UbMoVzbo70s The Cure \n", + "7 0epOFNiUfyON9EYx7Tpr6V The Strokes \n", + "8 40Yq4vzPs9VNUrIBG5Jr2i The Smashing Pumpkins \n", + "9 5UqTO8smerMvxHYA5xsXb6 Sonic Youth \n", + "10 3G3Gdm0ZRAOxLrbyjfhii5 my bloody valentine \n", + "11 72X6FHxaShda0XeQw3vbeF Slowdive \n", + "12 7w29UYBi0qsHi5RTcv3lmA Björk \n", + "13 3nnQpaTvKb5jCQabZefACI Jeff Buckley \n", + "14 3WaJSfKnzc65VDgmj2zU8B Interpol \n", + "15 6Ghvu1VvMGScGpOUJBAHNH Deftones \n", + "16 3kjuyTCjPG1WMFCiyc5IuB Arcade Fire \n", + "17 1nJvji2KIlWSseXRSlNYsC The Velvet Underground \n", + "18 6FXMGgJwohJLUSr5nVlf9X Massive Attack \n", + "19 2ApaG60P4r0yhBoDCGD8YG Elliott Smith \n", + "\n", + " related_genres related_popularity \\\n", + "0 [alternative rock, art pop, art rock, electron... 54 \n", + "1 [alternative rock, boston rock, permanent wave... 68 \n", + "2 [alternative rock, britpop, madchester, perman... 67 \n", + "3 [madchester, new wave, permanent wave, rock, u... 74 \n", + "4 [alternative rock, art pop, dark pop, electron... 59 \n", + "5 [alternative rock, art rock, indie rock, madch... 61 \n", + "6 [new wave, permanent wave, rock, uk post-punk] 73 \n", + "7 [alternative rock, garage rock, modern rock, p... 73 \n", + "8 [alternative metal, alternative rock, grunge, ... 70 \n", + "9 [alternative rock, indie rock, noise pop, nois... 55 \n", + "10 [alternative rock, dream pop, noise pop, shoeg... 54 \n", + "11 [alternative rock, dream pop, nu gaze, reading... 60 \n", + "12 [alternative rock, art pop, electronica, exper... 59 \n", + "13 [melancholia, permanent wave, singer-songwriter] 61 \n", + "14 [alternative dance, alternative rock, indie ro... 61 \n", + "15 [alternative metal, nu metal, rap metal, rock,... 75 \n", + "16 [alternative rock, baroque pop, canadian indie... 62 \n", + "17 [alternative rock, melancholia, permanent wave... 60 \n", + "18 [downtempo, electronica, trip hop] 61 \n", + "19 [alternative rock, indie rock, melancholia, si... 62 \n", + "\n", + " related_followers artist_id \n", + "0 {'href': None, 'total': 985116} 4Z8W4fKeB5YxbusRsdQVPb \n", + "1 {'href': None, 'total': 2694003} 4Z8W4fKeB5YxbusRsdQVPb \n", + "2 {'href': None, 'total': 3099793} 4Z8W4fKeB5YxbusRsdQVPb \n", + "3 {'href': None, 'total': 4647089} 4Z8W4fKeB5YxbusRsdQVPb \n", + "4 {'href': None, 'total': 1851714} 4Z8W4fKeB5YxbusRsdQVPb \n", + "5 {'href': None, 'total': 2248108} 4Z8W4fKeB5YxbusRsdQVPb \n", + "6 {'href': None, 'total': 4886284} 4Z8W4fKeB5YxbusRsdQVPb \n", + "7 {'href': None, 'total': 5260718} 4Z8W4fKeB5YxbusRsdQVPb \n", + "8 {'href': None, 'total': 4762503} 4Z8W4fKeB5YxbusRsdQVPb \n", + "9 {'href': None, 'total': 1072692} 4Z8W4fKeB5YxbusRsdQVPb \n", + "10 {'href': None, 'total': 811456} 4Z8W4fKeB5YxbusRsdQVPb \n", + "11 {'href': None, 'total': 857825} 4Z8W4fKeB5YxbusRsdQVPb \n", + "12 {'href': None, 'total': 1917156} 4Z8W4fKeB5YxbusRsdQVPb \n", + "13 {'href': None, 'total': 1155378} 4Z8W4fKeB5YxbusRsdQVPb \n", + "14 {'href': None, 'total': 1616230} 4Z8W4fKeB5YxbusRsdQVPb \n", + "15 {'href': None, 'total': 4543728} 4Z8W4fKeB5YxbusRsdQVPb \n", + "16 {'href': None, 'total': 2233533} 4Z8W4fKeB5YxbusRsdQVPb \n", + "17 {'href': None, 'total': 1800640} 4Z8W4fKeB5YxbusRsdQVPb \n", + "18 {'href': None, 'total': 2076951} 4Z8W4fKeB5YxbusRsdQVPb \n", + "19 {'href': None, 'total': 1000573} 4Z8W4fKeB5YxbusRsdQVPb " + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#add a column with selected id artist\n", + "df_related_artists['artist_id'] = artist_id\n", + "df_related_artists\n", + "#añadimos artist_id en df_related_artists" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "id": "e94bdf9a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
related_idrelated_namerelated_genresrelated_popularityrelated_followersartist_idnamegenrespopularityfollowers
04CvTDPKA6W06DRfBnZKrauThom Yorke[alternative rock, art pop, art rock, electron...54{'href': None, 'total': 985116}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
16zvul52xwTWzilBZl6BUbTPixies[alternative rock, boston rock, permanent wave...68{'href': None, 'total': 2694003}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
27MhMgCo0Bl0Kukl93PZbYSBlur[alternative rock, britpop, madchester, perman...67{'href': None, 'total': 3099793}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
33yY2gUcIsjMr8hjo51PoJ8The Smiths[madchester, new wave, permanent wave, rock, u...74{'href': None, 'total': 4647089}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
46liAMWkVf5LH7YR9yfFy1YPortishead[alternative rock, art pop, dark pop, electron...59{'href': None, 'total': 1851714}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
5432R46LaYsJZV2Gmc4jUV5Joy Division[alternative rock, art rock, indie rock, madch...61{'href': None, 'total': 2248108}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
67bu3H8JO7d0UbMoVzbo70sThe Cure[new wave, permanent wave, rock, uk post-punk]73{'href': None, 'total': 4886284}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
70epOFNiUfyON9EYx7Tpr6VThe Strokes[alternative rock, garage rock, modern rock, p...73{'href': None, 'total': 5260718}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
840Yq4vzPs9VNUrIBG5Jr2iThe Smashing Pumpkins[alternative metal, alternative rock, grunge, ...70{'href': None, 'total': 4762503}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
95UqTO8smerMvxHYA5xsXb6Sonic Youth[alternative rock, indie rock, noise pop, nois...55{'href': None, 'total': 1072692}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
103G3Gdm0ZRAOxLrbyjfhii5my bloody valentine[alternative rock, dream pop, noise pop, shoeg...54{'href': None, 'total': 811456}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
1172X6FHxaShda0XeQw3vbeFSlowdive[alternative rock, dream pop, nu gaze, reading...60{'href': None, 'total': 857825}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
127w29UYBi0qsHi5RTcv3lmABjörk[alternative rock, art pop, electronica, exper...59{'href': None, 'total': 1917156}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
133nnQpaTvKb5jCQabZefACIJeff Buckley[melancholia, permanent wave, singer-songwriter]61{'href': None, 'total': 1155378}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
143WaJSfKnzc65VDgmj2zU8BInterpol[alternative dance, alternative rock, indie ro...61{'href': None, 'total': 1616230}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
156Ghvu1VvMGScGpOUJBAHNHDeftones[alternative metal, nu metal, rap metal, rock,...75{'href': None, 'total': 4543728}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
163kjuyTCjPG1WMFCiyc5IuBArcade Fire[alternative rock, baroque pop, canadian indie...62{'href': None, 'total': 2233533}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
171nJvji2KIlWSseXRSlNYsCThe Velvet Underground[alternative rock, melancholia, permanent wave...60{'href': None, 'total': 1800640}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
186FXMGgJwohJLUSr5nVlf9XMassive Attack[downtempo, electronica, trip hop]61{'href': None, 'total': 2076951}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
192ApaG60P4r0yhBoDCGD8YGElliott Smith[alternative rock, indie rock, melancholia, si...62{'href': None, 'total': 1000573}4Z8W4fKeB5YxbusRsdQVPbRadiohead[alternative rock, art rock, melancholia, oxfo...78{'href': None, 'total': 8884416}
\n", + "
" + ], + "text/plain": [ + " related_id related_name \\\n", + "0 4CvTDPKA6W06DRfBnZKrau Thom Yorke \n", + "1 6zvul52xwTWzilBZl6BUbT Pixies \n", + "2 7MhMgCo0Bl0Kukl93PZbYS Blur \n", + "3 3yY2gUcIsjMr8hjo51PoJ8 The Smiths \n", + "4 6liAMWkVf5LH7YR9yfFy1Y Portishead \n", + "5 432R46LaYsJZV2Gmc4jUV5 Joy Division \n", + "6 7bu3H8JO7d0UbMoVzbo70s The Cure \n", + "7 0epOFNiUfyON9EYx7Tpr6V The Strokes \n", + "8 40Yq4vzPs9VNUrIBG5Jr2i The Smashing Pumpkins \n", + "9 5UqTO8smerMvxHYA5xsXb6 Sonic Youth \n", + "10 3G3Gdm0ZRAOxLrbyjfhii5 my bloody valentine \n", + "11 72X6FHxaShda0XeQw3vbeF Slowdive \n", + "12 7w29UYBi0qsHi5RTcv3lmA Björk \n", + "13 3nnQpaTvKb5jCQabZefACI Jeff Buckley \n", + "14 3WaJSfKnzc65VDgmj2zU8B Interpol \n", + "15 6Ghvu1VvMGScGpOUJBAHNH Deftones \n", + "16 3kjuyTCjPG1WMFCiyc5IuB Arcade Fire \n", + "17 1nJvji2KIlWSseXRSlNYsC The Velvet Underground \n", + "18 6FXMGgJwohJLUSr5nVlf9X Massive Attack \n", + "19 2ApaG60P4r0yhBoDCGD8YG Elliott Smith \n", + "\n", + " related_genres related_popularity \\\n", + "0 [alternative rock, art pop, art rock, electron... 54 \n", + "1 [alternative rock, boston rock, permanent wave... 68 \n", + "2 [alternative rock, britpop, madchester, perman... 67 \n", + "3 [madchester, new wave, permanent wave, rock, u... 74 \n", + "4 [alternative rock, art pop, dark pop, electron... 59 \n", + "5 [alternative rock, art rock, indie rock, madch... 61 \n", + "6 [new wave, permanent wave, rock, uk post-punk] 73 \n", + "7 [alternative rock, garage rock, modern rock, p... 73 \n", + "8 [alternative metal, alternative rock, grunge, ... 70 \n", + "9 [alternative rock, indie rock, noise pop, nois... 55 \n", + "10 [alternative rock, dream pop, noise pop, shoeg... 54 \n", + "11 [alternative rock, dream pop, nu gaze, reading... 60 \n", + "12 [alternative rock, art pop, electronica, exper... 59 \n", + "13 [melancholia, permanent wave, singer-songwriter] 61 \n", + "14 [alternative dance, alternative rock, indie ro... 61 \n", + "15 [alternative metal, nu metal, rap metal, rock,... 75 \n", + "16 [alternative rock, baroque pop, canadian indie... 62 \n", + "17 [alternative rock, melancholia, permanent wave... 60 \n", + "18 [downtempo, electronica, trip hop] 61 \n", + "19 [alternative rock, indie rock, melancholia, si... 62 \n", + "\n", + " related_followers artist_id name \\\n", + "0 {'href': None, 'total': 985116} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "1 {'href': None, 'total': 2694003} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "2 {'href': None, 'total': 3099793} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "3 {'href': None, 'total': 4647089} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "4 {'href': None, 'total': 1851714} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "5 {'href': None, 'total': 2248108} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "6 {'href': None, 'total': 4886284} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "7 {'href': None, 'total': 5260718} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "8 {'href': None, 'total': 4762503} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "9 {'href': None, 'total': 1072692} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "10 {'href': None, 'total': 811456} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "11 {'href': None, 'total': 857825} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "12 {'href': None, 'total': 1917156} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "13 {'href': None, 'total': 1155378} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "14 {'href': None, 'total': 1616230} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "15 {'href': None, 'total': 4543728} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "16 {'href': None, 'total': 2233533} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "17 {'href': None, 'total': 1800640} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "18 {'href': None, 'total': 2076951} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "19 {'href': None, 'total': 1000573} 4Z8W4fKeB5YxbusRsdQVPb Radiohead \n", + "\n", + " genres popularity \\\n", + "0 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "1 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "2 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "3 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "4 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "5 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "6 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "7 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "8 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "9 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "10 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "11 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "12 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "13 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "14 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "15 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "16 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "17 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "18 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "19 [alternative rock, art rock, melancholia, oxfo... 78 \n", + "\n", + " followers \n", + "0 {'href': None, 'total': 8884416} \n", + "1 {'href': None, 'total': 8884416} \n", + "2 {'href': None, 'total': 8884416} \n", + "3 {'href': None, 'total': 8884416} \n", + "4 {'href': None, 'total': 8884416} \n", + "5 {'href': None, 'total': 8884416} \n", + "6 {'href': None, 'total': 8884416} \n", + "7 {'href': None, 'total': 8884416} \n", + "8 {'href': None, 'total': 8884416} \n", + "9 {'href': None, 'total': 8884416} \n", + "10 {'href': None, 'total': 8884416} \n", + "11 {'href': None, 'total': 8884416} \n", + "12 {'href': None, 'total': 8884416} \n", + "13 {'href': None, 'total': 8884416} \n", + "14 {'href': None, 'total': 8884416} \n", + "15 {'href': None, 'total': 8884416} \n", + "16 {'href': None, 'total': 8884416} \n", + "17 {'href': None, 'total': 8884416} \n", + "18 {'href': None, 'total': 8884416} \n", + "19 {'href': None, 'total': 8884416} " + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_related_artists = pd.merge(df_related_artists, df_artist, on=\"artist_id\")\n", + "df_related_artists\n", + "#unimos df_related_artists y df_artist" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "id": "77adb8d5", + "metadata": {}, + "outputs": [], + "source": [ + "my_list=list()# tengo una lista vacia\n", + "for x in df_related_artists['related_id'].to_list():#por cada elemento en related_id lo conviertes a lista\n", + " method = \"/top-tracks\"\n", + " argument = \"?market=ES\" # aqui creamos el full_endpoint\n", + " full_endpoint = base_url + resource + x + method + argument # por cada artists_id una llamada a top-tracks\n", + " my_list.append(requests.get(full_endpoint, headers = header_info).json())#meto en la lista vacia\n", + " #los top-tracks de cada artista relacionado" + ] + }, + { + "cell_type": "code", + "execution_count": 141, + "id": "b0d1a47c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Thom Yorke'" + ] + }, + "execution_count": 141, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#my_list[0]['tracks'][0]['artists'][0]['name']" + ] + }, + { + "cell_type": "code", + "execution_count": 144, + "id": "725573aa", + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
artist_nametrack_name
0Thom YorkeHearing Damage
1Thom YorkeSuspirium
2Thom YorkeDawn Chorus
3Thom YorkeBlack Swan
4Thom YorkeUnmade
.........
195Elliott SmithSomebody That I Used To Know
196Elliott SmithBallad Of Big Nothing
197Elliott SmithSpeed Trials
198Elliott SmithClementine
199Elliott SmithSon Of Sam
\n", + "

200 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " artist_name track_name\n", + "0 Thom Yorke Hearing Damage\n", + "1 Thom Yorke Suspirium\n", + "2 Thom Yorke Dawn Chorus\n", + "3 Thom Yorke Black Swan\n", + "4 Thom Yorke Unmade\n", + ".. ... ...\n", + "195 Elliott Smith Somebody That I Used To Know\n", + "196 Elliott Smith Ballad Of Big Nothing\n", + "197 Elliott Smith Speed Trials\n", + "198 Elliott Smith Clementine\n", + "199 Elliott Smith Son Of Sam\n", + "\n", + "[200 rows x 2 columns]" + ] + }, + "execution_count": 144, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "my_list_2 = list()#creo una lista 2\n", + "for x in range(len(my_list)): # por cada elemento del rango de la longitud de my_list esto recorre cada artista\n", + " for y in range(len(my_list[x]['tracks'])):#este recorre cada track de cada artista\n", + " my_list_2.append([my_list[x]['tracks'][y]['artists'][0]['name'], my_list[x]['tracks'][y]['name']])\n", + " #En mi lista_2 metemos el nombre del artista y cada cancion\n", + " #tenemos 20 artistas y 10 canciones por cada artista\n", + "my_list_2\n", + "pd.DataFrame(my_list_2, columns=['artist_name','track_name'])#convertimos la lista a un DataFrame de 2 columnas artista y tracks" ] }, { @@ -221,9 +2471,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:.conda-ironhack]", + "display_name": "Python (m1_env)", "language": "python", - "name": "conda-env-.conda-ironhack-py" + "name": "m1_env" }, "language_info": { "codemirror_mode": { @@ -235,7 +2485,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.11" + "version": "3.10.13" } }, "nbformat": 4,