diff --git a/lab-api-wrappers.ipynb b/lab-api-wrappers.ipynb new file mode 100644 index 0000000..1951735 --- /dev/null +++ b/lab-api-wrappers.ipynb @@ -0,0 +1,2932 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "36c4a83b-37bd-488f-b621-e7707b0a804a", + "metadata": {}, + "source": [ + "# Lab | API wrappers - Create your collection of songs & audio features" + ] + }, + { + "cell_type": "markdown", + "id": "41a55bec-be00-40e7-8f0c-fa004837f5fb", + "metadata": {}, + "source": [ + "#### Instructions \n", + "\n", + "\n", + "To move forward with the project, you need to create a collection of songs with their audio features - as large as possible! \n", + "\n", + "These are the songs that we will cluster. And, later, when the user inputs a song, we will find the cluster to which the song belongs and recommend a song from the same cluster.\n", + "The more songs you have, the more accurate and diverse recommendations you'll be able to give. Although... you might want to make sure the collected songs are \"curated\" in a certain way. Try to find playlists of songs that are diverse, but also that meet certain standards.\n", + "\n", + "The process of sending hundreds or thousands of requests can take some time - it's normal if you have to wait a few minutes (or, if you're ambitious, even hours) to get all the data you need.\n", + "\n", + "An idea for collecting as many songs as possible is to start with all the songs of a big, diverse playlist and then go to every artist present in the playlist and grab every song of every album of that artist. The amount of songs you'll be collecting per playlist will grow exponentially!" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "b1560e44-5d7e-426f-b1c4-e2047655873e", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "import pandas as pd\n", + "\n", + "import spotipy\n", + "from spotipy.oauth2 import SpotifyClientCredentials" + ] + }, + { + "cell_type": "markdown", + "id": "08b7d890-35a8-448a-b764-10892b8ed0f1", + "metadata": {}, + "source": [ + "### Way 1: following example from the internet" + ] + }, + { + "cell_type": "markdown", + "id": "b1bbac3c-52aa-43eb-9d77-ecd130ea76d6", + "metadata": {}, + "source": [ + "see: https://towardsdatascience.com/discovering-your-music-taste-with-python-and-spotify-api-b51b0d2744d" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "bf60f73f-b2da-4199-b499-8689cedf77a5", + "metadata": {}, + "outputs": [], + "source": [ + "client_id = '65dc8168bce1489ca751fd70199efe57' #insert your client id\n", + "client_secret = '26ce94c460e04f3691296058097f8135' # insert your client secret id here\n", + "\n", + "client_credentials_manager = SpotifyClientCredentials(client_id, client_secret)\n", + "sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)\n", + "\n", + "playlist_1 = 'https://open.spotify.com/playlist/7d3ajghsmx2caVTM4pqIMg?si=a73924480ba844b5' #insert your playlist id\n", + "results_1 = sp.playlist(playlist_1)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "3b90f964-0e18-4d9b-859b-5db9be177cc0", + "metadata": {}, + "outputs": [], + "source": [ + "# create a list of song ids\n", + "ids=[]\n", + "\n", + "for item in results_1['tracks']['items']:\n", + " track = item['track']['id']\n", + " ids.append(track)\n", + " \n", + "song_meta={'id':[],'album':[], 'name':[], \n", + " 'artist':[],'explicit':[],'popularity':[]}\n", + "\n", + "for song_id in ids:\n", + " # get song's meta data\n", + " meta = sp.track(song_id)\n", + " \n", + " # song id\n", + " song_meta['id'].append(song_id)\n", + "\n", + " # album name\n", + " album=meta['album']['name']\n", + " song_meta['album']+=[album]\n", + "\n", + " # song name\n", + " song=meta['name']\n", + " song_meta['name']+=[song]\n", + " \n", + " # artists name\n", + " s = ', '\n", + " artist=s.join([singer_name['name'] for singer_name in meta['artists']])\n", + " song_meta['artist']+=[artist]\n", + " \n", + " # explicit: lyrics could be considered offensive or unsuitable for children\n", + " explicit=meta['explicit']\n", + " song_meta['explicit'].append(explicit)\n", + " \n", + " # song popularity\n", + " popularity=meta['popularity']\n", + " song_meta['popularity'].append(popularity)\n", + "\n", + "song_meta_df=pd.DataFrame.from_dict(song_meta)\n", + "\n", + "# check the song feature\n", + "features = sp.audio_features(song_meta['id'])\n", + "# change dictionary to dataframe\n", + "features_df=pd.DataFrame.from_dict(features)\n", + "\n", + "# convert milliseconds to mins\n", + "# duration_ms: The duration of the track in milliseconds.\n", + "# 1 minute = 60 seconds = 60 × 1000 milliseconds = 60,000 ms\n", + "features_df['duration_ms']=features_df['duration_ms']/60000\n", + "\n", + "# combine two dataframe\n", + "final_df=song_meta_df.merge(features_df)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "6c378834-b7e5-404c-85c2-041016580eb1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(27, 23)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final_df.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "3c97fe69-79bd-4cf3-91fd-25d14fa439ed", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['id', 'album', 'name', 'artist', 'explicit', 'popularity',\n", + " 'danceability', 'energy', 'key', 'loudness', 'mode', 'speechiness',\n", + " 'acousticness', 'instrumentalness', 'liveness', 'valence', 'tempo',\n", + " 'type', 'uri', 'track_href', 'analysis_url', 'duration_ms',\n", + " 'time_signature'],\n", + " dtype='object')" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final_df.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "245fdcf5-7b64-49ee-ab5c-1a9dd40e4287", + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idalbumnameartistexplicitpopularitydanceabilityenergykeyloudness...instrumentalnesslivenessvalencetempotypeuritrack_hrefanalysis_urlduration_mstime_signature
00vAio6riryryWWwmkKbBfCChristmas & ChillWinter ThingsAriana GrandeFalse00.5070.2070-10.215...0.0000000.22900.77468.600audio_featuresspotify:track:0vAio6riryryWWwmkKbBfChttps://api.spotify.com/v1/tracks/0vAio6riryry...https://api.spotify.com/v1/audio-analysis/0vAi...2.6453334
11OjmlSFuzYflWjSMTCyTJvLike It's ChristmasLike It's ChristmasJonas BrothersFalse540.7250.5711-6.007...0.0000000.05190.610146.035audio_featuresspotify:track:1OjmlSFuzYflWjSMTCyTJvhttps://api.spotify.com/v1/tracks/1OjmlSFuzYfl...https://api.spotify.com/v1/audio-analysis/1Ojm...3.3480004
25a1iz510sv2W9Dt1MvFd5RChristmas (Deluxe Special Edition)It's Beginning to Look a Lot like ChristmasMichael BubléFalse650.3390.2144-11.714...0.0000070.34100.36394.775audio_featuresspotify:track:5a1iz510sv2W9Dt1MvFd5Rhttps://api.spotify.com/v1/tracks/5a1iz510sv2W...https://api.spotify.com/v1/audio-analysis/5a1i...3.4440003
37xapw9Oy21WpfEcib2ErSAUnder The Mistletoe (Deluxe Edition)MistletoeJustin BieberFalse650.6570.5606-9.049...0.0000000.07940.854161.993audio_featuresspotify:track:7xapw9Oy21WpfEcib2ErSAhttps://api.spotify.com/v1/tracks/7xapw9Oy21Wp...https://api.spotify.com/v1/audio-analysis/7xap...3.0491174
40bYg9bo50gSsH3LtXe2SQnMerry ChristmasAll I Want for Christmas Is YouMariah CareyFalse720.3360.6277-7.463...0.0000000.07080.350150.273audio_featuresspotify:track:0bYg9bo50gSsH3LtXe2SQnhttps://api.spotify.com/v1/tracks/0bYg9bo50gSs...https://api.spotify.com/v1/audio-analysis/0bYg...4.0184504
51ADjWm8QNhgNV8yCNNgQ1TSanta Tell MeSanta Tell MeAriana GrandeFalse00.4640.6307-7.337...0.0000000.29500.527132.960audio_featuresspotify:track:1ADjWm8QNhgNV8yCNNgQ1Thttps://api.spotify.com/v1/tracks/1ADjWm8QNhgN...https://api.spotify.com/v1/audio-analysis/1ADj...3.4015505
61Qi2wh8fFgDV7tl4Sj3f2KHave Yourself A Merry Little ChristmasHave Yourself A Merry Little ChristmasSam SmithFalse540.4380.1785-9.402...0.0000000.31600.34475.248audio_featuresspotify:track:1Qi2wh8fFgDV7tl4Sj3f2Khttps://api.spotify.com/v1/tracks/1Qi2wh8fFgDV...https://api.spotify.com/v1/audio-analysis/1Qi2...2.8494001
70RIu23uyX5MTWApqfP549nLast ChristmasLast ChristmasAriana GrandeFalse00.6730.7947-2.758...0.0000000.09340.786102.961audio_featuresspotify:track:0RIu23uyX5MTWApqfP549nhttps://api.spotify.com/v1/tracks/0RIu23uyX5MT...https://api.spotify.com/v1/audio-analysis/0RIu...3.4113334
80zXjeGMMe7esPTvqJCN5d8A Very Special Christmas 25th AnniversaryWinter WonderlandJason MrazFalse250.6090.3595-6.715...0.0000000.22100.645145.178audio_featuresspotify:track:0zXjeGMMe7esPTvqJCN5d8https://api.spotify.com/v1/tracks/0zXjeGMMe7es...https://api.spotify.com/v1/audio-analysis/0zXj...2.1180004
90mansMnyTsIp9ALspSyLwLLove Is EverythingLove Is EverythingAriana GrandeFalse00.5650.92711-3.473...0.0000000.16800.808180.064audio_featuresspotify:track:0mansMnyTsIp9ALspSyLwLhttps://api.spotify.com/v1/tracks/0mansMnyTsIp...https://api.spotify.com/v1/audio-analysis/0man...3.5626674
103eYnKe0LhQA1B5HEkQaRTPUnder The Mistletoe (Deluxe Edition)The Christmas Song (Chestnuts Roasting On An O...Justin Bieber, UsherFalse480.5330.4369-9.542...0.0000000.10200.169103.477audio_featuresspotify:track:3eYnKe0LhQA1B5HEkQaRTPhttps://api.spotify.com/v1/tracks/3eYnKe0LhQA1...https://api.spotify.com/v1/audio-analysis/3eYn...3.5860003
115BYz6McvNTXD60vRFLkIMwHoliday For Swing!Baby, It's Cold OutsideSeth MacFarlane, Sara BareillesFalse260.5570.4629-7.093...0.0000000.08330.551119.125audio_featuresspotify:track:5BYz6McvNTXD60vRFLkIMwhttps://api.spotify.com/v1/tracks/5BYz6McvNTXD...https://api.spotify.com/v1/audio-analysis/5BYz...2.9786674
124Sb4ZLaYApWRk0fKLah9rBThe Big Christmas AlbumMy Only Wish (This Year)Santa Claus, Santa Clause, Silent NightFalse00.7110.7197-8.151...0.0000000.11300.575146.956audio_featuresspotify:track:4Sb4ZLaYApWRk0fKLah9rBhttps://api.spotify.com/v1/tracks/4Sb4ZLaYApWR...https://api.spotify.com/v1/audio-analysis/4Sb4...4.3817004
131MwqAFLFhVGgfo30y1dXpeSanta BabySanta BabyAriana Grande, Liz GilliesFalse00.7560.7810-5.722...0.0000000.30100.80896.012audio_featuresspotify:track:1MwqAFLFhVGgfo30y1dXpehttps://api.spotify.com/v1/tracks/1MwqAFLFhVGg...https://api.spotify.com/v1/audio-analysis/1Mwq...2.8584504
145o9JHeY8e47bXCjSZOnD7bThat's Christmas To MeWinter Wonderland / Don't Worry Be Happy (feat...Pentatonix, Tori KellyFalse00.5300.3986-8.506...0.0000000.08580.717129.592audio_featuresspotify:track:5o9JHeY8e47bXCjSZOnD7bhttps://api.spotify.com/v1/tracks/5o9JHeY8e47b...https://api.spotify.com/v1/audio-analysis/5o9J...3.4642174
156tjituizSxwSmBB5vtgHZEChristmasHolly Jolly ChristmasMichael BubléFalse480.6470.4657-8.308...0.0000000.08820.699151.251audio_featuresspotify:track:6tjituizSxwSmBB5vtgHZEhttps://api.spotify.com/v1/tracks/6tjituizSxwS...https://api.spotify.com/v1/audio-analysis/6tji...1.9964504
160VJ3I1e8WKHpMXEEtx0tLNHave Yourself A Merry Little Christmas - SingleHave Yourself A Merry Little ChristmasAndrew BelleFalse180.6390.4493-7.768...0.0153000.12900.130122.020audio_featuresspotify:track:0VJ3I1e8WKHpMXEEtx0tLNhttps://api.spotify.com/v1/tracks/0VJ3I1e8WKHp...https://api.spotify.com/v1/audio-analysis/0VJ3...3.8212834
173dwQdPUdCoxq3q9gCv5nbnSnow In CaliforniaSnow In CaliforniaAriana GrandeFalse00.6090.5411-5.997...0.0000000.33200.477134.795audio_featuresspotify:track:3dwQdPUdCoxq3q9gCv5nbnhttps://api.spotify.com/v1/tracks/3dwQdPUdCoxq...https://api.spotify.com/v1/audio-analysis/3dwQ...3.4613334
182wCPMWR3y4xclijuCcLJv7Four ChristmasesJingle Bell RockBobby HelmsFalse00.7090.5062-5.628...0.0000000.06200.682119.345audio_featuresspotify:track:2wCPMWR3y4xclijuCcLJv7https://api.spotify.com/v1/tracks/2wCPMWR3y4xc...https://api.spotify.com/v1/audio-analysis/2wCP...2.1924504
195hslUAKq9I9CG2bAulFkHNThe Andy Williams Christmas AlbumIt's the Most Wonderful Time of the YearAndy WilliamsFalse640.2400.5987-8.435...0.0000000.11700.776201.629audio_featuresspotify:track:5hslUAKq9I9CG2bAulFkHNhttps://api.spotify.com/v1/tracks/5hslUAKq9I9C...https://api.spotify.com/v1/audio-analysis/5hsl...2.5322173
201prYSRBfwPvE3v8jSRZL3QMy Kind Of ChristmasLet It Snow, Let It Snow, Let It SnowDean MartinFalse00.5040.2871-11.109...0.0000020.21800.707133.928audio_featuresspotify:track:1prYSRBfwPvE3v8jSRZL3Qhttps://api.spotify.com/v1/tracks/1prYSRBfwPvE...https://api.spotify.com/v1/audio-analysis/1prY...1.9597834
215PuKlCjfEVIXl0ZBp5ZW9gChristmas (Deluxe Special Edition)Holly Jolly ChristmasMichael BubléFalse590.6470.4657-8.308...0.0000000.08820.699151.251audio_featuresspotify:track:5PuKlCjfEVIXl0ZBp5ZW9ghttps://api.spotify.com/v1/tracks/5PuKlCjfEVIX...https://api.spotify.com/v1/audio-analysis/5PuK...1.9964504
227taXf5odg9xCAZERYfyOkSThe Definite BestFeliz NavidadJosé FelicianoFalse540.4850.8572-7.059...0.0000000.34700.963148.749audio_featuresspotify:track:7taXf5odg9xCAZERYfyOkShttps://api.spotify.com/v1/tracks/7taXf5odg9xC...https://api.spotify.com/v1/audio-analysis/7taX...3.0393334
231RMDXedcRno6rDBCbNHDJfChristmas (Deluxe Special Edition)Santa Claus Is Coming to TownMichael BubléFalse540.5940.38910-7.109...0.0000000.03130.396122.331audio_featuresspotify:track:1RMDXedcRno6rDBCbNHDJfhttps://api.spotify.com/v1/tracks/1RMDXedcRno6...https://api.spotify.com/v1/audio-analysis/1RMD...2.8515504
242L9QLAhrvtP4EYg1lY0TnwA Winter RomanceRudolph The Red-Nosed ReindeerDean MartinFalse500.4780.2017-16.768...0.0000000.08540.857136.471audio_featuresspotify:track:2L9QLAhrvtP4EYg1lY0Tnwhttps://api.spotify.com/v1/tracks/2L9QLAhrvtP4...https://api.spotify.com/v1/audio-analysis/2L9Q...2.2626674
2510JBIfvldDR2TnT5sphGc2Save Me, San Francisco (Golden Gate Edition)Shake up ChristmasTrainFalse00.4920.8280-2.140...0.0000000.34200.56781.409audio_featuresspotify:track:10JBIfvldDR2TnT5sphGc2https://api.spotify.com/v1/tracks/10JBIfvldDR2...https://api.spotify.com/v1/audio-analysis/10JB...3.8702174
263Xr6kOC4De4Lk41lF9nzTyUnder The Mistletoe (Deluxe Edition)Christmas LoveJustin BieberFalse00.6320.51510-8.444...0.0000000.32900.47399.936audio_featuresspotify:track:3Xr6kOC4De4Lk41lF9nzTyhttps://api.spotify.com/v1/tracks/3Xr6kOC4De4L...https://api.spotify.com/v1/audio-analysis/3Xr6...3.4464504
\n", + "

27 rows × 23 columns

\n", + "
" + ], + "text/plain": [ + " id album \\\n", + "0 0vAio6riryryWWwmkKbBfC Christmas & Chill \n", + "1 1OjmlSFuzYflWjSMTCyTJv Like It's Christmas \n", + "2 5a1iz510sv2W9Dt1MvFd5R Christmas (Deluxe Special Edition) \n", + "3 7xapw9Oy21WpfEcib2ErSA Under The Mistletoe (Deluxe Edition) \n", + "4 0bYg9bo50gSsH3LtXe2SQn Merry Christmas \n", + "5 1ADjWm8QNhgNV8yCNNgQ1T Santa Tell Me \n", + "6 1Qi2wh8fFgDV7tl4Sj3f2K Have Yourself A Merry Little Christmas \n", + "7 0RIu23uyX5MTWApqfP549n Last Christmas \n", + "8 0zXjeGMMe7esPTvqJCN5d8 A Very Special Christmas 25th Anniversary \n", + "9 0mansMnyTsIp9ALspSyLwL Love Is Everything \n", + "10 3eYnKe0LhQA1B5HEkQaRTP Under The Mistletoe (Deluxe Edition) \n", + "11 5BYz6McvNTXD60vRFLkIMw Holiday For Swing! \n", + "12 4Sb4ZLaYApWRk0fKLah9rB The Big Christmas Album \n", + "13 1MwqAFLFhVGgfo30y1dXpe Santa Baby \n", + "14 5o9JHeY8e47bXCjSZOnD7b That's Christmas To Me \n", + "15 6tjituizSxwSmBB5vtgHZE Christmas \n", + "16 0VJ3I1e8WKHpMXEEtx0tLN Have Yourself A Merry Little Christmas - Single \n", + "17 3dwQdPUdCoxq3q9gCv5nbn Snow In California \n", + "18 2wCPMWR3y4xclijuCcLJv7 Four Christmases \n", + "19 5hslUAKq9I9CG2bAulFkHN The Andy Williams Christmas Album \n", + "20 1prYSRBfwPvE3v8jSRZL3Q My Kind Of Christmas \n", + "21 5PuKlCjfEVIXl0ZBp5ZW9g Christmas (Deluxe Special Edition) \n", + "22 7taXf5odg9xCAZERYfyOkS The Definite Best \n", + "23 1RMDXedcRno6rDBCbNHDJf Christmas (Deluxe Special Edition) \n", + "24 2L9QLAhrvtP4EYg1lY0Tnw A Winter Romance \n", + "25 10JBIfvldDR2TnT5sphGc2 Save Me, San Francisco (Golden Gate Edition) \n", + "26 3Xr6kOC4De4Lk41lF9nzTy Under The Mistletoe (Deluxe Edition) \n", + "\n", + " name \\\n", + "0 Winter Things \n", + "1 Like It's Christmas \n", + "2 It's Beginning to Look a Lot like Christmas \n", + "3 Mistletoe \n", + "4 All I Want for Christmas Is You \n", + "5 Santa Tell Me \n", + "6 Have Yourself A Merry Little Christmas \n", + "7 Last Christmas \n", + "8 Winter Wonderland \n", + "9 Love Is Everything \n", + "10 The Christmas Song (Chestnuts Roasting On An O... \n", + "11 Baby, It's Cold Outside \n", + "12 My Only Wish (This Year) \n", + "13 Santa Baby \n", + "14 Winter Wonderland / Don't Worry Be Happy (feat... \n", + "15 Holly Jolly Christmas \n", + "16 Have Yourself A Merry Little Christmas \n", + "17 Snow In California \n", + "18 Jingle Bell Rock \n", + "19 It's the Most Wonderful Time of the Year \n", + "20 Let It Snow, Let It Snow, Let It Snow \n", + "21 Holly Jolly Christmas \n", + "22 Feliz Navidad \n", + "23 Santa Claus Is Coming to Town \n", + "24 Rudolph The Red-Nosed Reindeer \n", + "25 Shake up Christmas \n", + "26 Christmas Love \n", + "\n", + " artist explicit popularity \\\n", + "0 Ariana Grande False 0 \n", + "1 Jonas Brothers False 54 \n", + "2 Michael Bublé False 65 \n", + "3 Justin Bieber False 65 \n", + "4 Mariah Carey False 72 \n", + "5 Ariana Grande False 0 \n", + "6 Sam Smith False 54 \n", + "7 Ariana Grande False 0 \n", + "8 Jason Mraz False 25 \n", + "9 Ariana Grande False 0 \n", + "10 Justin Bieber, Usher False 48 \n", + "11 Seth MacFarlane, Sara Bareilles False 26 \n", + "12 Santa Claus, Santa Clause, Silent Night False 0 \n", + "13 Ariana Grande, Liz Gillies False 0 \n", + "14 Pentatonix, Tori Kelly False 0 \n", + "15 Michael Bublé False 48 \n", + "16 Andrew Belle False 18 \n", + "17 Ariana Grande False 0 \n", + "18 Bobby Helms False 0 \n", + "19 Andy Williams False 64 \n", + "20 Dean Martin False 0 \n", + "21 Michael Bublé False 59 \n", + "22 José Feliciano False 54 \n", + "23 Michael Bublé False 54 \n", + "24 Dean Martin False 50 \n", + "25 Train False 0 \n", + "26 Justin Bieber False 0 \n", + "\n", + " danceability energy key loudness ... instrumentalness liveness \\\n", + "0 0.507 0.207 0 -10.215 ... 0.000000 0.2290 \n", + "1 0.725 0.571 1 -6.007 ... 0.000000 0.0519 \n", + "2 0.339 0.214 4 -11.714 ... 0.000007 0.3410 \n", + "3 0.657 0.560 6 -9.049 ... 0.000000 0.0794 \n", + "4 0.336 0.627 7 -7.463 ... 0.000000 0.0708 \n", + "5 0.464 0.630 7 -7.337 ... 0.000000 0.2950 \n", + "6 0.438 0.178 5 -9.402 ... 0.000000 0.3160 \n", + "7 0.673 0.794 7 -2.758 ... 0.000000 0.0934 \n", + "8 0.609 0.359 5 -6.715 ... 0.000000 0.2210 \n", + "9 0.565 0.927 11 -3.473 ... 0.000000 0.1680 \n", + "10 0.533 0.436 9 -9.542 ... 0.000000 0.1020 \n", + "11 0.557 0.462 9 -7.093 ... 0.000000 0.0833 \n", + "12 0.711 0.719 7 -8.151 ... 0.000000 0.1130 \n", + "13 0.756 0.781 0 -5.722 ... 0.000000 0.3010 \n", + "14 0.530 0.398 6 -8.506 ... 0.000000 0.0858 \n", + "15 0.647 0.465 7 -8.308 ... 0.000000 0.0882 \n", + "16 0.639 0.449 3 -7.768 ... 0.015300 0.1290 \n", + "17 0.609 0.541 1 -5.997 ... 0.000000 0.3320 \n", + "18 0.709 0.506 2 -5.628 ... 0.000000 0.0620 \n", + "19 0.240 0.598 7 -8.435 ... 0.000000 0.1170 \n", + "20 0.504 0.287 1 -11.109 ... 0.000002 0.2180 \n", + "21 0.647 0.465 7 -8.308 ... 0.000000 0.0882 \n", + "22 0.485 0.857 2 -7.059 ... 0.000000 0.3470 \n", + "23 0.594 0.389 10 -7.109 ... 0.000000 0.0313 \n", + "24 0.478 0.201 7 -16.768 ... 0.000000 0.0854 \n", + "25 0.492 0.828 0 -2.140 ... 0.000000 0.3420 \n", + "26 0.632 0.515 10 -8.444 ... 0.000000 0.3290 \n", + "\n", + " valence tempo type uri \\\n", + "0 0.774 68.600 audio_features spotify:track:0vAio6riryryWWwmkKbBfC \n", + "1 0.610 146.035 audio_features spotify:track:1OjmlSFuzYflWjSMTCyTJv \n", + "2 0.363 94.775 audio_features spotify:track:5a1iz510sv2W9Dt1MvFd5R \n", + "3 0.854 161.993 audio_features spotify:track:7xapw9Oy21WpfEcib2ErSA \n", + "4 0.350 150.273 audio_features spotify:track:0bYg9bo50gSsH3LtXe2SQn \n", + "5 0.527 132.960 audio_features spotify:track:1ADjWm8QNhgNV8yCNNgQ1T \n", + "6 0.344 75.248 audio_features spotify:track:1Qi2wh8fFgDV7tl4Sj3f2K \n", + "7 0.786 102.961 audio_features spotify:track:0RIu23uyX5MTWApqfP549n \n", + "8 0.645 145.178 audio_features spotify:track:0zXjeGMMe7esPTvqJCN5d8 \n", + "9 0.808 180.064 audio_features spotify:track:0mansMnyTsIp9ALspSyLwL \n", + "10 0.169 103.477 audio_features spotify:track:3eYnKe0LhQA1B5HEkQaRTP \n", + "11 0.551 119.125 audio_features spotify:track:5BYz6McvNTXD60vRFLkIMw \n", + "12 0.575 146.956 audio_features spotify:track:4Sb4ZLaYApWRk0fKLah9rB \n", + "13 0.808 96.012 audio_features spotify:track:1MwqAFLFhVGgfo30y1dXpe \n", + "14 0.717 129.592 audio_features spotify:track:5o9JHeY8e47bXCjSZOnD7b \n", + "15 0.699 151.251 audio_features spotify:track:6tjituizSxwSmBB5vtgHZE \n", + "16 0.130 122.020 audio_features spotify:track:0VJ3I1e8WKHpMXEEtx0tLN \n", + "17 0.477 134.795 audio_features spotify:track:3dwQdPUdCoxq3q9gCv5nbn \n", + "18 0.682 119.345 audio_features spotify:track:2wCPMWR3y4xclijuCcLJv7 \n", + "19 0.776 201.629 audio_features spotify:track:5hslUAKq9I9CG2bAulFkHN \n", + "20 0.707 133.928 audio_features spotify:track:1prYSRBfwPvE3v8jSRZL3Q \n", + "21 0.699 151.251 audio_features spotify:track:5PuKlCjfEVIXl0ZBp5ZW9g \n", + "22 0.963 148.749 audio_features spotify:track:7taXf5odg9xCAZERYfyOkS \n", + "23 0.396 122.331 audio_features spotify:track:1RMDXedcRno6rDBCbNHDJf \n", + "24 0.857 136.471 audio_features spotify:track:2L9QLAhrvtP4EYg1lY0Tnw \n", + "25 0.567 81.409 audio_features spotify:track:10JBIfvldDR2TnT5sphGc2 \n", + "26 0.473 99.936 audio_features spotify:track:3Xr6kOC4De4Lk41lF9nzTy \n", + "\n", + " track_href \\\n", + "0 https://api.spotify.com/v1/tracks/0vAio6riryry... \n", + "1 https://api.spotify.com/v1/tracks/1OjmlSFuzYfl... \n", + "2 https://api.spotify.com/v1/tracks/5a1iz510sv2W... \n", + "3 https://api.spotify.com/v1/tracks/7xapw9Oy21Wp... \n", + "4 https://api.spotify.com/v1/tracks/0bYg9bo50gSs... \n", + "5 https://api.spotify.com/v1/tracks/1ADjWm8QNhgN... \n", + "6 https://api.spotify.com/v1/tracks/1Qi2wh8fFgDV... \n", + "7 https://api.spotify.com/v1/tracks/0RIu23uyX5MT... \n", + "8 https://api.spotify.com/v1/tracks/0zXjeGMMe7es... \n", + "9 https://api.spotify.com/v1/tracks/0mansMnyTsIp... \n", + "10 https://api.spotify.com/v1/tracks/3eYnKe0LhQA1... \n", + "11 https://api.spotify.com/v1/tracks/5BYz6McvNTXD... \n", + "12 https://api.spotify.com/v1/tracks/4Sb4ZLaYApWR... \n", + "13 https://api.spotify.com/v1/tracks/1MwqAFLFhVGg... \n", + "14 https://api.spotify.com/v1/tracks/5o9JHeY8e47b... \n", + "15 https://api.spotify.com/v1/tracks/6tjituizSxwS... \n", + "16 https://api.spotify.com/v1/tracks/0VJ3I1e8WKHp... \n", + "17 https://api.spotify.com/v1/tracks/3dwQdPUdCoxq... \n", + "18 https://api.spotify.com/v1/tracks/2wCPMWR3y4xc... \n", + "19 https://api.spotify.com/v1/tracks/5hslUAKq9I9C... \n", + "20 https://api.spotify.com/v1/tracks/1prYSRBfwPvE... \n", + "21 https://api.spotify.com/v1/tracks/5PuKlCjfEVIX... \n", + "22 https://api.spotify.com/v1/tracks/7taXf5odg9xC... \n", + "23 https://api.spotify.com/v1/tracks/1RMDXedcRno6... \n", + "24 https://api.spotify.com/v1/tracks/2L9QLAhrvtP4... \n", + "25 https://api.spotify.com/v1/tracks/10JBIfvldDR2... \n", + "26 https://api.spotify.com/v1/tracks/3Xr6kOC4De4L... \n", + "\n", + " analysis_url duration_ms \\\n", + "0 https://api.spotify.com/v1/audio-analysis/0vAi... 2.645333 \n", + "1 https://api.spotify.com/v1/audio-analysis/1Ojm... 3.348000 \n", + "2 https://api.spotify.com/v1/audio-analysis/5a1i... 3.444000 \n", + "3 https://api.spotify.com/v1/audio-analysis/7xap... 3.049117 \n", + "4 https://api.spotify.com/v1/audio-analysis/0bYg... 4.018450 \n", + "5 https://api.spotify.com/v1/audio-analysis/1ADj... 3.401550 \n", + "6 https://api.spotify.com/v1/audio-analysis/1Qi2... 2.849400 \n", + "7 https://api.spotify.com/v1/audio-analysis/0RIu... 3.411333 \n", + "8 https://api.spotify.com/v1/audio-analysis/0zXj... 2.118000 \n", + "9 https://api.spotify.com/v1/audio-analysis/0man... 3.562667 \n", + "10 https://api.spotify.com/v1/audio-analysis/3eYn... 3.586000 \n", + "11 https://api.spotify.com/v1/audio-analysis/5BYz... 2.978667 \n", + "12 https://api.spotify.com/v1/audio-analysis/4Sb4... 4.381700 \n", + "13 https://api.spotify.com/v1/audio-analysis/1Mwq... 2.858450 \n", + "14 https://api.spotify.com/v1/audio-analysis/5o9J... 3.464217 \n", + "15 https://api.spotify.com/v1/audio-analysis/6tji... 1.996450 \n", + "16 https://api.spotify.com/v1/audio-analysis/0VJ3... 3.821283 \n", + "17 https://api.spotify.com/v1/audio-analysis/3dwQ... 3.461333 \n", + "18 https://api.spotify.com/v1/audio-analysis/2wCP... 2.192450 \n", + "19 https://api.spotify.com/v1/audio-analysis/5hsl... 2.532217 \n", + "20 https://api.spotify.com/v1/audio-analysis/1prY... 1.959783 \n", + "21 https://api.spotify.com/v1/audio-analysis/5PuK... 1.996450 \n", + "22 https://api.spotify.com/v1/audio-analysis/7taX... 3.039333 \n", + "23 https://api.spotify.com/v1/audio-analysis/1RMD... 2.851550 \n", + "24 https://api.spotify.com/v1/audio-analysis/2L9Q... 2.262667 \n", + "25 https://api.spotify.com/v1/audio-analysis/10JB... 3.870217 \n", + "26 https://api.spotify.com/v1/audio-analysis/3Xr6... 3.446450 \n", + "\n", + " time_signature \n", + "0 4 \n", + "1 4 \n", + "2 3 \n", + "3 4 \n", + "4 4 \n", + "5 5 \n", + "6 1 \n", + "7 4 \n", + "8 4 \n", + "9 4 \n", + "10 3 \n", + "11 4 \n", + "12 4 \n", + "13 4 \n", + "14 4 \n", + "15 4 \n", + "16 4 \n", + "17 4 \n", + "18 4 \n", + "19 3 \n", + "20 4 \n", + "21 4 \n", + "22 4 \n", + "23 4 \n", + "24 4 \n", + "25 4 \n", + "26 4 \n", + "\n", + "[27 rows x 23 columns]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final_df" + ] + }, + { + "cell_type": "markdown", + "id": "45f7c6a6-cbfc-49d1-ad25-e2e11306eb05", + "metadata": {}, + "source": [ + "### Way 2: following the class example" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "8d2a8571-bb2a-4047-8c85-f4a008931bfb", + "metadata": {}, + "outputs": [], + "source": [ + "sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=\"65dc8168bce1489ca751fd70199efe57\",\n", + " client_secret=\"26ce94c460e04f3691296058097f8135\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "bbc597ce-eb81-4b19-a774-a0a22aa8aca7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "123" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results_2 = sp.user_playlist_tracks(\"spotify\", \"37i9dQZF1DX0Yxoavh5qJV\")\n", + "tracks = results_2['items']\n", + "\n", + "for oset in range(100,results_2['total'],100):\n", + " results_2 = sp.user_playlist_tracks(\"spotify\", \"37i9dQZF1DX0Yxoavh5qJV\", offset=oset)\n", + " tracks += results_2['items']\n", + "len(tracks)" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "id": "8a6dcb93-e6fb-4b08-a02e-613c739960cb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['href', 'items', 'limit', 'next', 'offset', 'previous', 'total'])" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results_2.keys()" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "id": "33caed98-3c29-4bc7-b8b0-0a14e2d8f6cf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['added_at', 'added_by', 'is_local', 'primary_color', 'track', 'video_thumbnail'])" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results_2['items'][0].keys()" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "id": "5e435168-572d-45d1-b0a5-631476882082", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'album': {'album_type': 'album',\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/2lolQgalUvZDfp5vvVtTYV'},\n", + " 'href': 'https://api.spotify.com/v1/artists/2lolQgalUvZDfp5vvVtTYV',\n", + " 'id': '2lolQgalUvZDfp5vvVtTYV',\n", + " 'name': 'Tony Bennett',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2lolQgalUvZDfp5vvVtTYV'}],\n", + " 'available_markets': [],\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/album/2sw2JVdzZ4lcn2cxh3Nxdc'},\n", + " 'href': 'https://api.spotify.com/v1/albums/2sw2JVdzZ4lcn2cxh3Nxdc',\n", + " 'id': '2sw2JVdzZ4lcn2cxh3Nxdc',\n", + " 'images': [{'height': 640,\n", + " 'url': 'https://i.scdn.co/image/ab67616d0000b273835d52eb61628600e466ead9',\n", + " 'width': 640},\n", + " {'height': 300,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00001e02835d52eb61628600e466ead9',\n", + " 'width': 300},\n", + " {'height': 64,\n", + " 'url': 'https://i.scdn.co/image/ab67616d00004851835d52eb61628600e466ead9',\n", + " 'width': 64}],\n", + " 'name': 'Snowfall - The Tony Bennett Christmas Album',\n", + " 'release_date': '1968-11-06',\n", + " 'release_date_precision': 'day',\n", + " 'total_tracks': 11,\n", + " 'type': 'album',\n", + " 'uri': 'spotify:album:2sw2JVdzZ4lcn2cxh3Nxdc'},\n", + " 'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/2lolQgalUvZDfp5vvVtTYV'},\n", + " 'href': 'https://api.spotify.com/v1/artists/2lolQgalUvZDfp5vvVtTYV',\n", + " 'id': '2lolQgalUvZDfp5vvVtTYV',\n", + " 'name': 'Tony Bennett',\n", + " 'type': 'artist',\n", + " 'uri': 'spotify:artist:2lolQgalUvZDfp5vvVtTYV'}],\n", + " 'available_markets': [],\n", + " 'disc_number': 1,\n", + " 'duration_ms': 133866,\n", + " 'episode': False,\n", + " 'explicit': False,\n", + " 'external_ids': {'isrc': 'USSM19400327'},\n", + " 'external_urls': {'spotify': 'https://open.spotify.com/track/4ricyQVd20UQde1jpXCSuJ'},\n", + " 'href': 'https://api.spotify.com/v1/tracks/4ricyQVd20UQde1jpXCSuJ',\n", + " 'id': '4ricyQVd20UQde1jpXCSuJ',\n", + " 'is_local': False,\n", + " 'name': 'Winter Wonderland',\n", + " 'popularity': 23,\n", + " 'preview_url': None,\n", + " 'track': True,\n", + " 'track_number': 8,\n", + " 'type': 'track',\n", + " 'uri': 'spotify:track:4ricyQVd20UQde1jpXCSuJ'}" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results_2['items'][0]['track']#['album']['name']" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "id": "85bcf464-275a-4c87-8d3b-d98d9e1f0a76", + "metadata": {}, + "outputs": [], + "source": [ + "def get_song_from_playlist(playlist=[]):\n", + " \n", + " tracks_from_playlist = playlist\n", + " \n", + " songs = []\n", + " \n", + " for track in tracks_from_playlist:\n", + " songs.append(track['track']['name'])\n", + " \n", + " return list(set(songs))" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "id": "309b3d1f-305c-4a82-8bdb-6ea136504106", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Fairytale of New York (feat. Kirsty MacColl)',\n", + " 'White Christmas - Spotify Singles - Holiday, Recorded at Air Studios, London',\n", + " 'Driving Home for Christmas',\n", + " 'Silent Night',\n", + " 'Mistletoe',\n", + " 'A Holly Jolly Christmas',\n", + " 'Merry Christmas Baby',\n", + " 'Grown-Up Christmas List',\n", + " 'Do You Hear What I Hear? - Remastered 2006',\n", + " 'Christmas Time',\n", + " \"It's Beginning To Look A Lot Like Christmas\",\n", + " 'Joy To The World',\n", + " 'Step Into Christmas',\n", + " 'I Need You Christmas',\n", + " 'Happy Xmas (War Is Over)',\n", + " 'Man With The Bag',\n", + " 'Frosty the Snowman',\n", + " 'Frosty The Snowman',\n", + " \"It's Christmas\",\n", + " 'Merry Christmas, Happy Holidays',\n", + " \"Rockin' Around The Christmas Tree - Single Version\",\n", + " 'Snowman',\n", + " 'I Saw Mommy Kissing Santa Claus',\n", + " 'Oh Holy Night - Recorded at Metropolis Studios, London',\n", + " 'Run Rudolph Run',\n", + " 'Christmas Without You',\n", + " 'The Lighthouse Keeper',\n", + " \"It's Not Christmas 'Til You Come Home - Recorded At Spotify Studios NYC\",\n", + " 'Please Come Home for Christmas - 2013 Remaster',\n", + " \"It's the Most Wonderful Time of the Year\",\n", + " 'Santa Baby - Bonus',\n", + " 'Christmas Time Is Here',\n", + " 'All I Want for Christmas Is You',\n", + " \"Like It's Christmas\",\n", + " 'All I Want (For Christmas)',\n", + " 'Christmas C’mon',\n", + " 'Underneath the Tree',\n", + " 'Christmas Time Is Here - Recorded at Sound Emporium Nashville',\n", + " \"I'll Be Home\",\n", + " 'Bring Me Love',\n", + " 'Glittery - From The Kacey Musgraves Christmas Show',\n", + " 'The Christmas Song (Shawn Mendes & Camila Cabello)',\n", + " 'Cuddle Up, Cozy Down Christmas',\n", + " 'Cozy Little Christmas',\n", + " 'Holly Jolly Christmas',\n", + " 'Make It To Christmas',\n", + " 'Last Christmas',\n", + " 'Take Me Home For Christmas',\n", + " 'Oh Santa! (feat. Ariana Grande & Jennifer Hudson)',\n", + " 'My Kind Of Present',\n", + " 'Mistletoe and Holly',\n", + " 'A Holly Jolly Christmas - Single Version',\n", + " 'The Christmas Song (Chestnuts Roasting On An Open Fire)',\n", + " \"It's Beginning to Look a Lot Like Christmas (with Mitchell Ayres & His Orchestra)\",\n", + " \"Santa's Coming for Us\",\n", + " \"Rockin' Around The Christmas Tree\",\n", + " 'The Christmas Song (Merry Christmas To You)',\n", + " 'Jingle Bell Rock',\n", + " '2000 Miles - 2007 Remaster',\n", + " 'Holidays (feat. Earth, Wind & Fire)',\n", + " 'Little Drummer Boy',\n", + " \"It's The Most Wonderful Time of the Year\",\n", + " 'You and Me and Christmastime',\n", + " \"Baby, It's Cold Outside (feat. Meghan Trainor)\",\n", + " 'Wonderful Christmastime (Edited Version) [Remastered]',\n", + " 'White Christmas',\n", + " 'Have Yourself A Merry Little Christmas',\n", + " 'Wrapped in Red',\n", + " 'Let It Snow, Let It Snow, Let It Snow',\n", + " 'Mistletoe and Wine',\n", + " 'The First Noël (with Faith Hill)',\n", + " 'Lonely This Christmas',\n", + " 'Merry Christmas Everyone - Remastered',\n", + " 'I Wish It Could Be Christmas Everyday',\n", + " 'Christmas (Baby Please Come Home)',\n", + " 'What Christmas Means To Me',\n", + " \"Do They Know It's Christmas? - 1984 Version\",\n", + " \"Santa Claus Is Comin' to Town - Live at C.W. Post College, Greenvale, NY - December 1975\",\n", + " 'Jingle Bells',\n", + " \"I'll Be Home for Christmas\",\n", + " \"Baby, It's Cold Outside - Remastered 2004\",\n", + " 'Santa Claus Is Coming to Town',\n", + " 'Amazing Grace (My Chains Are Gone)',\n", + " 'Here Comes Santa Claus (Right Down Santa Claus Lane)',\n", + " 'Naughty List (with Dixie)',\n", + " 'Have Yourself a Merry Little Christmas',\n", + " 'Santa Baby',\n", + " \"Thank God It's Christmas\",\n", + " 'O Holy Night',\n", + " \"It's Beginning to Look a Lot like Christmas\",\n", + " 'This Christmas',\n", + " 'Santa Claus Is Coming To Town',\n", + " 'Christmas Tree Farm',\n", + " 'Christmas Love',\n", + " 'Before Christmas',\n", + " 'Sleigh Ride',\n", + " 'One More Sleep',\n", + " 'Christmas Lights',\n", + " 'Happy Xmas (War Is Over) - Remastered 2010',\n", + " 'Blame It On The Mistletoe',\n", + " 'My Only Wish (This Year)',\n", + " 'Santa Tell Me',\n", + " 'Let It Snow (with Babyface)',\n", + " 'Rudolph The Red-Nosed Reindeer',\n", + " 'Blue Christmas',\n", + " \"Baby It's Cold Outside (duet with Michael Bublé)\",\n", + " 'Shake up Christmas',\n", + " 'Winter Wonderland',\n", + " 'Feliz Navidad',\n", + " 'You Make It Feel Like Christmas (feat. Blake Shelton)',\n", + " 'Under The Mistletoe',\n", + " 'Let It Snow! Let It Snow! Let It Snow! (with The B. Swanson Quartet)']" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "songs = get_song_from_playlist(tracks)\n", + "songs" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "id": "7cf3a6e5-c17a-412d-bf59-54ac3c4f533c", + "metadata": {}, + "outputs": [], + "source": [ + "def get_song_id_from_playlist(playlist=[]):\n", + " \n", + " tracks_from_playlist = playlist\n", + " \n", + " song_id = []\n", + " \n", + " for track in tracks_from_playlist:\n", + " song_id.append(track['track']['id'])\n", + " \n", + " return list(set(song_id))" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "id": "25948ceb-5bb8-45fb-a80e-ea9f4120ab2d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['7uoFMmxln0GPXQ0AcCBXRq',\n", + " '1prYSRBfwPvE3v8jSRZL3Q',\n", + " '6MPpnJDLk37GEIM0iGGITd',\n", + " '5DMItYJluCFc7YtFdP4aXo',\n", + " '2nMZx7QHerfo4Wv37xNUEC',\n", + " '3QIoEi8Enr9uHffwInGIsC',\n", + " '6RS6rcjnWrdfVuu2U2W2dj',\n", + " '7F9oCEKbqjN99cV5HpvYER',\n", + " '2FWKbF1s4s5Z8ZQkyIGNQU',\n", + " '7Hz6LLOVxrojLPIHJJ1S0E',\n", + " '15sxLiiChE5dCW3Y756oas',\n", + " '23lpJkE7jJ4BVQhc3lj0VM',\n", + " '2qoZNAP3JLyIOtbsPtBjvV',\n", + " '1moEucbMhmAK6KVPoNw6ms',\n", + " '5MknXpAUgINT11lxoobaJK',\n", + " '0Ie5uiv54KgCr7P4sYDTHl',\n", + " '2mvabkN1i2gLnGAPUVdwek',\n", + " '32h59T8q2SonUPJ006lyXt',\n", + " '3VTNVsTTu05dmTsVFrmGpK',\n", + " '4i1xD9JHGoRaXcKdmjA4yj',\n", + " '4uQqahi1iUP35xE2qGdKdo',\n", + " '1sFWEpf1aPYN576LS1aa4Y',\n", + " '0YupMLYOYz6lZDbN3kRt7A',\n", + " '0YWUHZPJVg4iujddsJDwhM',\n", + " '5jjsm4Jjq8xjDaue3rW9Go',\n", + " '7inXu0Eaeg02VsM8kHNvzM',\n", + " '4KV9bM7a1KDc7b7OakFZic',\n", + " '1OjmlSFuzYflWjSMTCyTJv',\n", + " '5Q2P43CJra0uRAogjHyJDK',\n", + " '10HDoLPz2bucGBkoNEjDHW',\n", + " '3Xr6kOC4De4Lk41lF9nzTy',\n", + " '2K4XbdyLxi9jhqVQeyUKRK',\n", + " '78pn8k7RogKo2oxl0DyX6d',\n", + " '6yaxdh87KVj82QIYKTP1zt',\n", + " '3nAp4IvdMPPWEH9uuXFFV5',\n", + " '4fzyvSu73BhGvi96p2zwjL',\n", + " '1RMDXedcRno6rDBCbNHDJf',\n", + " '2eLPefNqdtcTN1pCEqlrWr',\n", + " '2wCPMWR3y4xclijuCcLJv7',\n", + " '0viGbbEJ9xV6qNJsTaXruz',\n", + " '1Ri9P0ZPrqr6h0REDRdJBd',\n", + " '4Z0l8dIngsalL0QdCun5CE',\n", + " '5DHfUmmnlFJPqa9MnKe0EX',\n", + " '0iV9yfj1knFNOSEiuTHZwl',\n", + " '4hrQGaFalrGJfcsILMxjuc',\n", + " '1dinW5tLGDdPhxtW8vMkUn',\n", + " '1XBc4r6ltXjkFJBrsttwIF',\n", + " '3BhlC2eX8obANfmLEwo1ia',\n", + " '7dvkUNutBgT1tw41tpvpUh',\n", + " '32OWobmyAz8J2qA8iWekyS',\n", + " '1mH6tZC6iXIHPI6EixCwxw',\n", + " '7n7VsX3sv66znBwA8b5uhp',\n", + " '30WHma5z5Sty54jbtoxYEy',\n", + " '0fwxmtpxpMmEMphmJbCAEx',\n", + " '3zJw3rugfpVrmBeDDnUYzy',\n", + " '110lWlsa8fJXgrrwGgg0f1',\n", + " '4M3K1gnHJnE3cIrAcKZQr3',\n", + " '5aDoUmxBsbdpS16alksb5Z',\n", + " '6YJdPrH3i2POzu7hdHIRrb',\n", + " '3Z3QhZAZpqwZa1phsbQ3JZ',\n", + " '5PuKlCjfEVIXl0ZBp5ZW9g',\n", + " '1h9QQ7e222OSr93MRiMqGZ',\n", + " '3PIDciSFdrQxSQSihim3hN',\n", + " '5DoGwwQAlYumpSSlDNMOwY',\n", + " '4PS1e8f2LvuTFgUs1Cn3ON',\n", + " '1deT8vP3lOVU3XFAKHsSc3',\n", + " '5a1iz510sv2W9Dt1MvFd5R',\n", + " '1F8tXdM8cz9bH5PiK1SuAB',\n", + " '4y69lx0SFFZZrcbyy9sV6n',\n", + " '60fWsdGYfKDNkNitrk1DIW',\n", + " '6XzpeMXDvLC86GvAfnUsIA',\n", + " '5cXne3fQ8Q2vbSMwGjunM8',\n", + " '25xgW0go6n2VEyiTclAkBK',\n", + " '79a2ejVzj2SpXkpWdfv1Co',\n", + " '5hslUAKq9I9CG2bAulFkHN',\n", + " '4ricyQVd20UQde1jpXCSuJ',\n", + " '0JoLc8rgQBJhDMolSCuRuw',\n", + " '6C81GGUCNbEmR8gMIi0CpH',\n", + " '6MtecozqUbilB5qbVARrUH',\n", + " '10JBIfvldDR2TnT5sphGc2',\n", + " '3AlpkljBS1AU7HFVPms8K6',\n", + " '2pXpURmn6zC5ZYDMms6fwa',\n", + " '1eh5mDCjo7XbDNY5tYiNVU',\n", + " '7taXf5odg9xCAZERYfyOkS',\n", + " '6oIpL9XkEhyo0bDrCagQQY',\n", + " '0tXPhc8LvM4dPvoRwI66XQ',\n", + " '2dbfjsBbi3nt0a173iUumA',\n", + " '0QtJZpyfZF67QF32p41NXa',\n", + " '7uMwRRjTbAnpamA9cc842p',\n", + " '0cM5URUqqQTpJWonmdzF1J',\n", + " '2WUVQQAsWvScEdBVilRYaR',\n", + " '5wTM2Bm8phDwHAuOsfBwhU',\n", + " '5xDrO9DEDJGUQGfyoHvgDJ',\n", + " '4so0Wek9Ig1p6CRCHuINwW',\n", + " '2QpN1ZVw8eJO5f7WcvUA1k',\n", + " '35ys6iS1supcwFoxLJkFbg',\n", + " '7lbto9KYTHq5V1PetjIMOF',\n", + " '72HP2M4jjw4t0AIGdEVGEF',\n", + " '5SBSN8IJo4kJP3umV27zaY',\n", + " '38xhBO2AKrJnjdjVnhJES6',\n", + " '2Y0ktCGrGoGcQFXsGztvhi',\n", + " '2L9QLAhrvtP4EYg1lY0Tnw',\n", + " '4dFtIGQBrYjiskk7fN5Wmx',\n", + " '1ADjWm8QNhgNV8yCNNgQ1T',\n", + " '1GpPsjjd4D1jsteGYpGGIN',\n", + " '0Yeh2VJCsxSgbftSGTiUbN',\n", + " '0bYg9bo50gSsH3LtXe2SQn',\n", + " '3AgiRs3oxc2dFh0CPUHXJs',\n", + " '1sEC3X76vXgpsgnfaXEMwR',\n", + " '5ASM6Qjiav2xPe7gRkQMsQ',\n", + " '5SyQ5OhqrkJGb35V7RBoL0',\n", + " '6Lv9ozIdb06duB01e6ZpNQ',\n", + " '2rkb8ijsPapKDMEh0cSe8I',\n", + " '0PhwkzKlhXvSbStP34MbGv',\n", + " '2zs2Ck470VmBFTwUp4NFdv',\n", + " '18g50kFt5uwVeCzQbrCvAO',\n", + " '1QLZKzC2pjP4ySf4ALrNhm',\n", + " '1hvpDAxZPKjKztOc72sv06',\n", + " '3jKGG4THqegu6EgxinAIYm',\n", + " '02FaKXXL7KUtRc7K0k54tL',\n", + " '0QPYn15U8IQHKcH2LDfrek',\n", + " '0yS8P7DFNEBYQ5yHadM5z0',\n", + " '3QiAAp20rPC3dcAtKtMaqQ']" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "song_id = get_song_id_from_playlist(tracks)\n", + "song_id" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "29abd33a-d09f-4b5d-b8a0-3ca2d186a324", + "metadata": {}, + "outputs": [], + "source": [ + "def get_artists_from_playlist(playlist=[]):\n", + " \n", + " tracks_from_playlist = playlist\n", + " \n", + " artists = []\n", + " \n", + " for track in tracks_from_playlist:\n", + " artists_info = track['track']['artists']\n", + " \n", + " for artist_info in artists_info:\n", + " artists.append(artist_info['name'])\n", + " \n", + " return list(set(artists))" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "ceb1cac3-2a5c-458d-83ba-3cf86a45ee0e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Coldplay',\n", + " 'Ella Fitzgerald',\n", + " 'Jennifer Lopez',\n", + " 'Mariah Carey',\n", + " 'Mel & Kim',\n", + " 'Chris Rea',\n", + " 'Yoko Ono',\n", + " 'ROZES',\n", + " 'Fiona Apple',\n", + " 'Natalie Taylor',\n", + " 'Blake Shelton',\n", + " 'Nat King Cole',\n", + " 'Paul McCartney',\n", + " 'José Feliciano',\n", + " 'Chuck Berry',\n", + " 'Sia',\n", + " 'Tori Kelly',\n", + " 'Elvis Presley',\n", + " 'Lindsey Stirling',\n", + " 'Jordan Smith',\n", + " 'Wizzard',\n", + " 'Camila Cabello',\n", + " 'Perry Como',\n", + " 'Liam Payne',\n", + " 'Kirsty MacColl',\n", + " 'Atlantic Holiday',\n", + " 'Jonas Brothers',\n", + " 'Tony Bennett',\n", + " 'Bing Crosby',\n", + " 'Shawn Mendes',\n", + " 'Stevie Wonder',\n", + " 'Band Aid',\n", + " 'Hannah Kerr',\n", + " 'The Pogues',\n", + " 'The Plastic Ono Band',\n", + " 'Gwen Stefani',\n", + " 'AJ Mitchell',\n", + " 'Josh Groban',\n", + " 'Usher',\n", + " \"Shakin' Stevens\",\n", + " 'Troye Sivan',\n", + " 'THE ELEVEN',\n", + " 'Meghan Trainor',\n", + " 'Frank Sinatra',\n", + " 'Britney Spears',\n", + " 'Bobby Helms',\n", + " 'Dixie',\n", + " 'Stevie Mackey',\n", + " 'The Ronettes',\n", + " 'Jessie J',\n", + " 'Becky G',\n", + " 'Céline Dion',\n", + " 'B. Swanson Quartet',\n", + " 'Liz Gillies',\n", + " 'Earth, Wind & Fire',\n", + " 'Mitchell Ayres & His Orchestra',\n", + " 'Kelly Clarkson',\n", + " 'George Ezra',\n", + " 'James TW',\n", + " 'Katy Perry',\n", + " 'Burl Ives',\n", + " 'Faith Hill',\n", + " 'Christina Aguilera',\n", + " 'Kacey Musgraves',\n", + " 'Train',\n", + " 'Andy Williams',\n", + " 'Andreas Weise',\n", + " 'Darlene Love',\n", + " 'John Legend',\n", + " 'Ken Darby Singers',\n", + " 'The Fontane Sisters',\n", + " 'Idina Menzel',\n", + " 'Leona Lewis',\n", + " 'Dolly Parton',\n", + " 'Jennifer Hudson',\n", + " 'Daryl Hall & John Oates',\n", + " 'Babyface',\n", + " 'The Jackson 5',\n", + " '*NSYNC',\n", + " 'Norah Jones',\n", + " 'Brett Eldredge',\n", + " 'Pentatonix',\n", + " 'Alessia Cara',\n", + " 'John Lennon',\n", + " 'Pretenders',\n", + " 'Brenda Lee',\n", + " 'John Scott Trotter & His Orchestra',\n", + " 'Mud',\n", + " 'Ava Max',\n", + " 'Justin Bieber',\n", + " 'Eagles',\n", + " 'Sam Smith',\n", + " 'Nina Nesbitt',\n", + " 'Kylie Minogue',\n", + " 'Otis Redding',\n", + " 'Wham!',\n", + " 'Sheffield',\n", + " 'Devin Dawson',\n", + " 'Helene Fischer',\n", + " 'Bruce Springsteen',\n", + " 'Cliff Richard',\n", + " 'The Harlem Community Choir',\n", + " 'Ariana Grande',\n", + " 'Ella Henderson',\n", + " 'for KING & COUNTRY',\n", + " 'Donny Hathaway',\n", + " 'Elton John',\n", + " 'Queen',\n", + " 'Michael Bublé',\n", + " 'Dean Martin',\n", + " 'Jamie Cullum',\n", + " 'Backstreet Boys',\n", + " 'Dan + Shay',\n", + " 'Taylor Swift']" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "artists = get_artists_from_playlist(tracks)\n", + "artists" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "id": "560b0a1a-903d-45f3-8095-40df04339405", + "metadata": {}, + "outputs": [], + "source": [ + "def get_album_from_playlist(playlist=[]):\n", + " \n", + " tracks_from_playlist = playlist\n", + " \n", + " albums = []\n", + " \n", + " for track in tracks_from_playlist:\n", + " albums.append(track['track']['album']['name'])\n", + " \n", + " return list(set(album))" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "id": "68ecdad6-4ba0-464b-a543-1bd2d0fec78e", + "metadata": {}, + "outputs": [], + "source": [ + "def get_album_from_playlist(playlist=[]):\n", + " \n", + " tracks_from_playlist = playlist\n", + " \n", + " albums = []\n", + " \n", + " for track in tracks_from_playlist:\n", + " album_info = track['track']['album']\n", + " \n", + " for album in album_info:\n", + " albums.append(album_info['name'])\n", + " \n", + " return list(set(album))" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "id": "75e0a2de-3f75-4caa-8dee-334875be1567", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['i', 'r', 'u']" + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "albums = get_album_from_playlist(tracks)\n", + "albums" + ] + }, + { + "cell_type": "markdown", + "id": "2fa6a5e1-da04-4704-a4fc-36f44b4e7f8f", + "metadata": {}, + "source": [ + "--> why does this not work?" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "id": "dd80f675-d9e6-4884-b236-ed51596aa06a", + "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", + "
idnameartist
07uoFMmxln0GPXQ0AcCBXRqFairytale of New York (feat. Kirsty MacColl)Coldplay
11prYSRBfwPvE3v8jSRZL3QWhite Christmas - Spotify Singles - Holiday, R...Ella Fitzgerald
26MPpnJDLk37GEIM0iGGITdDriving Home for ChristmasJennifer Lopez
35DMItYJluCFc7YtFdP4aXoSilent NightMariah Carey
42nMZx7QHerfo4Wv37xNUECMistletoeMel & Kim
............
1073AgiRs3oxc2dFh0CPUHXJsWinter WonderlandQueen
1081sEC3X76vXgpsgnfaXEMwRFeliz NavidadMichael Bublé
1095ASM6Qjiav2xPe7gRkQMsQYou Make It Feel Like Christmas (feat. Blake S...Dean Martin
1105SyQ5OhqrkJGb35V7RBoL0Under The MistletoeJamie Cullum
1116Lv9ozIdb06duB01e6ZpNQLet It Snow! Let It Snow! Let It Snow! (with T...Backstreet Boys
\n", + "

112 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " id \\\n", + "0 7uoFMmxln0GPXQ0AcCBXRq \n", + "1 1prYSRBfwPvE3v8jSRZL3Q \n", + "2 6MPpnJDLk37GEIM0iGGITd \n", + "3 5DMItYJluCFc7YtFdP4aXo \n", + "4 2nMZx7QHerfo4Wv37xNUEC \n", + ".. ... \n", + "107 3AgiRs3oxc2dFh0CPUHXJs \n", + "108 1sEC3X76vXgpsgnfaXEMwR \n", + "109 5ASM6Qjiav2xPe7gRkQMsQ \n", + "110 5SyQ5OhqrkJGb35V7RBoL0 \n", + "111 6Lv9ozIdb06duB01e6ZpNQ \n", + "\n", + " name artist \n", + "0 Fairytale of New York (feat. Kirsty MacColl) Coldplay \n", + "1 White Christmas - Spotify Singles - Holiday, R... Ella Fitzgerald \n", + "2 Driving Home for Christmas Jennifer Lopez \n", + "3 Silent Night Mariah Carey \n", + "4 Mistletoe Mel & Kim \n", + ".. ... ... \n", + "107 Winter Wonderland Queen \n", + "108 Feliz Navidad Michael Bublé \n", + "109 You Make It Feel Like Christmas (feat. Blake S... Dean Martin \n", + "110 Under The Mistletoe Jamie Cullum \n", + "111 Let It Snow! Let It Snow! Let It Snow! (with T... Backstreet Boys \n", + "\n", + "[112 rows x 3 columns]" + ] + }, + "execution_count": 100, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_2 = pd.DataFrame(list(zip(song_id, songs, artists)), columns =['id', 'name', 'artist'])\n", + "df_2" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "id": "886efc67-62fd-41a2-8bdf-d789d0c7a52e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(112, 3)" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_2.shape" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "id": "ecf8b7cb-b502-45c7-9598-1fbb0199bb16", + "metadata": {}, + "outputs": [], + "source": [ + "# check the song feature\n", + "features_1 = sp.audio_features(df_2['id'].iloc[:60])\n", + "features_2 = sp.audio_features(df_2['id'].iloc[60:])" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "id": "83637f21-f205-4846-882a-82233551f516", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(60, 52)" + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(features_1), len(features_2)" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "id": "015671bc-06dc-4d1d-92e2-79e03af9585a", + "metadata": {}, + "outputs": [], + "source": [ + "# change dictionary to dataframe\n", + "features_1_df = pd.DataFrame.from_dict(features_1)\n", + "features_2_df = pd.DataFrame.from_dict(features_2)" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "id": "9ac91fe9-b9cc-49ca-b3f2-46fc9114390a", + "metadata": {}, + "outputs": [], + "source": [ + "features_df = pd.concat([features_1_df, features_2_df], ignore_index=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "id": "fcfd8e41-0748-4002-8b89-485a850d6b82", + "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", + "
danceabilityenergykeyloudnessmodespeechinessacousticnessinstrumentalnesslivenessvalencetempotypeiduritrack_hrefanalysis_urlduration_mstime_signature
00.7160.5121-6.25710.03310.4830.0000000.09280.326104.957audio_features7uoFMmxln0GPXQ0AcCBXRqspotify:track:7uoFMmxln0GPXQ0AcCBXRqhttps://api.spotify.com/v1/tracks/7uoFMmxln0GP...https://api.spotify.com/v1/audio-analysis/7uoF...1659073
10.5040.2871-11.10910.03460.7820.0000020.21800.707133.928audio_features1prYSRBfwPvE3v8jSRZL3Qspotify:track:1prYSRBfwPvE3v8jSRZL3Qhttps://api.spotify.com/v1/tracks/1prYSRBfwPvE...https://api.spotify.com/v1/audio-analysis/1prY...1175874
20.5700.5108-8.14810.05700.7630.0000000.28500.84176.919audio_features6MPpnJDLk37GEIM0iGGITdspotify:track:6MPpnJDLk37GEIM0iGGITdhttps://api.spotify.com/v1/tracks/6MPpnJDLk37G...https://api.spotify.com/v1/audio-analysis/6MPp...1337734
30.5510.3250-13.50710.02860.8100.0001120.11500.49698.932audio_features5DMItYJluCFc7YtFdP4aXospotify:track:5DMItYJluCFc7YtFdP4aXohttps://api.spotify.com/v1/tracks/5DMItYJluCFc...https://api.spotify.com/v1/audio-analysis/5DMI...2131603
40.5400.7347-4.66810.03660.3650.0000000.13200.360123.877audio_features2nMZx7QHerfo4Wv37xNUECspotify:track:2nMZx7QHerfo4Wv37xNUEChttps://api.spotify.com/v1/tracks/2nMZx7QHerfo...https://api.spotify.com/v1/audio-analysis/2nMZ...2169074
.........................................................
1070.4980.4329-14.38610.03450.6880.0000000.13600.365135.015audio_features3AgiRs3oxc2dFh0CPUHXJsspotify:track:3AgiRs3oxc2dFh0CPUHXJshttps://api.spotify.com/v1/tracks/3AgiRs3oxc2d...https://api.spotify.com/v1/audio-analysis/3Agi...2453333
1080.1940.2963-10.42910.03220.7410.0000280.08620.12191.547audio_features1sEC3X76vXgpsgnfaXEMwRspotify:track:1sEC3X76vXgpsgnfaXEMwRhttps://api.spotify.com/v1/tracks/1sEC3X76vXgp...https://api.spotify.com/v1/audio-analysis/1sEC...2735733
1090.5290.7722-7.01310.02870.4030.0000020.31600.85391.751audio_features5ASM6Qjiav2xPe7gRkQMsQspotify:track:5ASM6Qjiav2xPe7gRkQMsQhttps://api.spotify.com/v1/tracks/5ASM6Qjiav2x...https://api.spotify.com/v1/audio-analysis/5ASM...1812674
1100.6500.9345-4.20910.04740.1160.0000000.86700.737105.001audio_features5SyQ5OhqrkJGb35V7RBoL0spotify:track:5SyQ5OhqrkJGb35V7RBoL0https://api.spotify.com/v1/tracks/5SyQ5OhqrkJG...https://api.spotify.com/v1/audio-analysis/5SyQ...2522004
1110.3380.4964-7.21210.02850.3270.0000050.16100.188173.980audio_features6Lv9ozIdb06duB01e6ZpNQspotify:track:6Lv9ozIdb06duB01e6ZpNQhttps://api.spotify.com/v1/tracks/6Lv9ozIdb06d...https://api.spotify.com/v1/audio-analysis/6Lv9...2672273
\n", + "

112 rows × 18 columns

\n", + "
" + ], + "text/plain": [ + " danceability energy key loudness mode speechiness acousticness \\\n", + "0 0.716 0.512 1 -6.257 1 0.0331 0.483 \n", + "1 0.504 0.287 1 -11.109 1 0.0346 0.782 \n", + "2 0.570 0.510 8 -8.148 1 0.0570 0.763 \n", + "3 0.551 0.325 0 -13.507 1 0.0286 0.810 \n", + "4 0.540 0.734 7 -4.668 1 0.0366 0.365 \n", + ".. ... ... ... ... ... ... ... \n", + "107 0.498 0.432 9 -14.386 1 0.0345 0.688 \n", + "108 0.194 0.296 3 -10.429 1 0.0322 0.741 \n", + "109 0.529 0.772 2 -7.013 1 0.0287 0.403 \n", + "110 0.650 0.934 5 -4.209 1 0.0474 0.116 \n", + "111 0.338 0.496 4 -7.212 1 0.0285 0.327 \n", + "\n", + " instrumentalness liveness valence tempo type \\\n", + "0 0.000000 0.0928 0.326 104.957 audio_features \n", + "1 0.000002 0.2180 0.707 133.928 audio_features \n", + "2 0.000000 0.2850 0.841 76.919 audio_features \n", + "3 0.000112 0.1150 0.496 98.932 audio_features \n", + "4 0.000000 0.1320 0.360 123.877 audio_features \n", + ".. ... ... ... ... ... \n", + "107 0.000000 0.1360 0.365 135.015 audio_features \n", + "108 0.000028 0.0862 0.121 91.547 audio_features \n", + "109 0.000002 0.3160 0.853 91.751 audio_features \n", + "110 0.000000 0.8670 0.737 105.001 audio_features \n", + "111 0.000005 0.1610 0.188 173.980 audio_features \n", + "\n", + " id uri \\\n", + "0 7uoFMmxln0GPXQ0AcCBXRq spotify:track:7uoFMmxln0GPXQ0AcCBXRq \n", + "1 1prYSRBfwPvE3v8jSRZL3Q spotify:track:1prYSRBfwPvE3v8jSRZL3Q \n", + "2 6MPpnJDLk37GEIM0iGGITd spotify:track:6MPpnJDLk37GEIM0iGGITd \n", + "3 5DMItYJluCFc7YtFdP4aXo spotify:track:5DMItYJluCFc7YtFdP4aXo \n", + "4 2nMZx7QHerfo4Wv37xNUEC spotify:track:2nMZx7QHerfo4Wv37xNUEC \n", + ".. ... ... \n", + "107 3AgiRs3oxc2dFh0CPUHXJs spotify:track:3AgiRs3oxc2dFh0CPUHXJs \n", + "108 1sEC3X76vXgpsgnfaXEMwR spotify:track:1sEC3X76vXgpsgnfaXEMwR \n", + "109 5ASM6Qjiav2xPe7gRkQMsQ spotify:track:5ASM6Qjiav2xPe7gRkQMsQ \n", + "110 5SyQ5OhqrkJGb35V7RBoL0 spotify:track:5SyQ5OhqrkJGb35V7RBoL0 \n", + "111 6Lv9ozIdb06duB01e6ZpNQ spotify:track:6Lv9ozIdb06duB01e6ZpNQ \n", + "\n", + " track_href \\\n", + "0 https://api.spotify.com/v1/tracks/7uoFMmxln0GP... \n", + "1 https://api.spotify.com/v1/tracks/1prYSRBfwPvE... \n", + "2 https://api.spotify.com/v1/tracks/6MPpnJDLk37G... \n", + "3 https://api.spotify.com/v1/tracks/5DMItYJluCFc... \n", + "4 https://api.spotify.com/v1/tracks/2nMZx7QHerfo... \n", + ".. ... \n", + "107 https://api.spotify.com/v1/tracks/3AgiRs3oxc2d... \n", + "108 https://api.spotify.com/v1/tracks/1sEC3X76vXgp... \n", + "109 https://api.spotify.com/v1/tracks/5ASM6Qjiav2x... \n", + "110 https://api.spotify.com/v1/tracks/5SyQ5OhqrkJG... \n", + "111 https://api.spotify.com/v1/tracks/6Lv9ozIdb06d... \n", + "\n", + " analysis_url duration_ms \\\n", + "0 https://api.spotify.com/v1/audio-analysis/7uoF... 165907 \n", + "1 https://api.spotify.com/v1/audio-analysis/1prY... 117587 \n", + "2 https://api.spotify.com/v1/audio-analysis/6MPp... 133773 \n", + "3 https://api.spotify.com/v1/audio-analysis/5DMI... 213160 \n", + "4 https://api.spotify.com/v1/audio-analysis/2nMZ... 216907 \n", + ".. ... ... \n", + "107 https://api.spotify.com/v1/audio-analysis/3Agi... 245333 \n", + "108 https://api.spotify.com/v1/audio-analysis/1sEC... 273573 \n", + "109 https://api.spotify.com/v1/audio-analysis/5ASM... 181267 \n", + "110 https://api.spotify.com/v1/audio-analysis/5SyQ... 252200 \n", + "111 https://api.spotify.com/v1/audio-analysis/6Lv9... 267227 \n", + "\n", + " time_signature \n", + "0 3 \n", + "1 4 \n", + "2 4 \n", + "3 3 \n", + "4 4 \n", + ".. ... \n", + "107 3 \n", + "108 3 \n", + "109 4 \n", + "110 4 \n", + "111 3 \n", + "\n", + "[112 rows x 18 columns]" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "features_df" + ] + }, + { + "cell_type": "code", + "execution_count": 117, + "id": "b09e2883-0374-4057-919d-4fef814f909a", + "metadata": {}, + "outputs": [], + "source": [ + "final_df_2 = df_2.merge(features_df, on='id')" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "id": "90d39df4-a04c-4543-b1ac-eac76884f9f6", + "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", + " \n", + " \n", + " \n", + "
idnameartistdanceabilityenergykeyloudnessmodespeechinessacousticnessinstrumentalnesslivenessvalencetempotypeuritrack_hrefanalysis_urlduration_mstime_signature
07uoFMmxln0GPXQ0AcCBXRqFairytale of New York (feat. Kirsty MacColl)Coldplay0.7160.5121-6.25710.03310.4830.0000000.09280.326104.957audio_featuresspotify:track:7uoFMmxln0GPXQ0AcCBXRqhttps://api.spotify.com/v1/tracks/7uoFMmxln0GP...https://api.spotify.com/v1/audio-analysis/7uoF...1659073
11prYSRBfwPvE3v8jSRZL3QWhite Christmas - Spotify Singles - Holiday, R...Ella Fitzgerald0.5040.2871-11.10910.03460.7820.0000020.21800.707133.928audio_featuresspotify:track:1prYSRBfwPvE3v8jSRZL3Qhttps://api.spotify.com/v1/tracks/1prYSRBfwPvE...https://api.spotify.com/v1/audio-analysis/1prY...1175874
26MPpnJDLk37GEIM0iGGITdDriving Home for ChristmasJennifer Lopez0.5700.5108-8.14810.05700.7630.0000000.28500.84176.919audio_featuresspotify:track:6MPpnJDLk37GEIM0iGGITdhttps://api.spotify.com/v1/tracks/6MPpnJDLk37G...https://api.spotify.com/v1/audio-analysis/6MPp...1337734
35DMItYJluCFc7YtFdP4aXoSilent NightMariah Carey0.5510.3250-13.50710.02860.8100.0001120.11500.49698.932audio_featuresspotify:track:5DMItYJluCFc7YtFdP4aXohttps://api.spotify.com/v1/tracks/5DMItYJluCFc...https://api.spotify.com/v1/audio-analysis/5DMI...2131603
42nMZx7QHerfo4Wv37xNUECMistletoeMel & Kim0.5400.7347-4.66810.03660.3650.0000000.13200.360123.877audio_featuresspotify:track:2nMZx7QHerfo4Wv37xNUEChttps://api.spotify.com/v1/tracks/2nMZx7QHerfo...https://api.spotify.com/v1/audio-analysis/2nMZ...2169074
...............................................................
1073AgiRs3oxc2dFh0CPUHXJsWinter WonderlandQueen0.4980.4329-14.38610.03450.6880.0000000.13600.365135.015audio_featuresspotify:track:3AgiRs3oxc2dFh0CPUHXJshttps://api.spotify.com/v1/tracks/3AgiRs3oxc2d...https://api.spotify.com/v1/audio-analysis/3Agi...2453333
1081sEC3X76vXgpsgnfaXEMwRFeliz NavidadMichael Bublé0.1940.2963-10.42910.03220.7410.0000280.08620.12191.547audio_featuresspotify:track:1sEC3X76vXgpsgnfaXEMwRhttps://api.spotify.com/v1/tracks/1sEC3X76vXgp...https://api.spotify.com/v1/audio-analysis/1sEC...2735733
1095ASM6Qjiav2xPe7gRkQMsQYou Make It Feel Like Christmas (feat. Blake S...Dean Martin0.5290.7722-7.01310.02870.4030.0000020.31600.85391.751audio_featuresspotify:track:5ASM6Qjiav2xPe7gRkQMsQhttps://api.spotify.com/v1/tracks/5ASM6Qjiav2x...https://api.spotify.com/v1/audio-analysis/5ASM...1812674
1105SyQ5OhqrkJGb35V7RBoL0Under The MistletoeJamie Cullum0.6500.9345-4.20910.04740.1160.0000000.86700.737105.001audio_featuresspotify:track:5SyQ5OhqrkJGb35V7RBoL0https://api.spotify.com/v1/tracks/5SyQ5OhqrkJG...https://api.spotify.com/v1/audio-analysis/5SyQ...2522004
1116Lv9ozIdb06duB01e6ZpNQLet It Snow! Let It Snow! Let It Snow! (with T...Backstreet Boys0.3380.4964-7.21210.02850.3270.0000050.16100.188173.980audio_featuresspotify:track:6Lv9ozIdb06duB01e6ZpNQhttps://api.spotify.com/v1/tracks/6Lv9ozIdb06d...https://api.spotify.com/v1/audio-analysis/6Lv9...2672273
\n", + "

112 rows × 20 columns

\n", + "
" + ], + "text/plain": [ + " id \\\n", + "0 7uoFMmxln0GPXQ0AcCBXRq \n", + "1 1prYSRBfwPvE3v8jSRZL3Q \n", + "2 6MPpnJDLk37GEIM0iGGITd \n", + "3 5DMItYJluCFc7YtFdP4aXo \n", + "4 2nMZx7QHerfo4Wv37xNUEC \n", + ".. ... \n", + "107 3AgiRs3oxc2dFh0CPUHXJs \n", + "108 1sEC3X76vXgpsgnfaXEMwR \n", + "109 5ASM6Qjiav2xPe7gRkQMsQ \n", + "110 5SyQ5OhqrkJGb35V7RBoL0 \n", + "111 6Lv9ozIdb06duB01e6ZpNQ \n", + "\n", + " name artist \\\n", + "0 Fairytale of New York (feat. Kirsty MacColl) Coldplay \n", + "1 White Christmas - Spotify Singles - Holiday, R... Ella Fitzgerald \n", + "2 Driving Home for Christmas Jennifer Lopez \n", + "3 Silent Night Mariah Carey \n", + "4 Mistletoe Mel & Kim \n", + ".. ... ... \n", + "107 Winter Wonderland Queen \n", + "108 Feliz Navidad Michael Bublé \n", + "109 You Make It Feel Like Christmas (feat. Blake S... Dean Martin \n", + "110 Under The Mistletoe Jamie Cullum \n", + "111 Let It Snow! Let It Snow! Let It Snow! (with T... Backstreet Boys \n", + "\n", + " danceability energy key loudness mode speechiness acousticness \\\n", + "0 0.716 0.512 1 -6.257 1 0.0331 0.483 \n", + "1 0.504 0.287 1 -11.109 1 0.0346 0.782 \n", + "2 0.570 0.510 8 -8.148 1 0.0570 0.763 \n", + "3 0.551 0.325 0 -13.507 1 0.0286 0.810 \n", + "4 0.540 0.734 7 -4.668 1 0.0366 0.365 \n", + ".. ... ... ... ... ... ... ... \n", + "107 0.498 0.432 9 -14.386 1 0.0345 0.688 \n", + "108 0.194 0.296 3 -10.429 1 0.0322 0.741 \n", + "109 0.529 0.772 2 -7.013 1 0.0287 0.403 \n", + "110 0.650 0.934 5 -4.209 1 0.0474 0.116 \n", + "111 0.338 0.496 4 -7.212 1 0.0285 0.327 \n", + "\n", + " instrumentalness liveness valence tempo type \\\n", + "0 0.000000 0.0928 0.326 104.957 audio_features \n", + "1 0.000002 0.2180 0.707 133.928 audio_features \n", + "2 0.000000 0.2850 0.841 76.919 audio_features \n", + "3 0.000112 0.1150 0.496 98.932 audio_features \n", + "4 0.000000 0.1320 0.360 123.877 audio_features \n", + ".. ... ... ... ... ... \n", + "107 0.000000 0.1360 0.365 135.015 audio_features \n", + "108 0.000028 0.0862 0.121 91.547 audio_features \n", + "109 0.000002 0.3160 0.853 91.751 audio_features \n", + "110 0.000000 0.8670 0.737 105.001 audio_features \n", + "111 0.000005 0.1610 0.188 173.980 audio_features \n", + "\n", + " uri \\\n", + "0 spotify:track:7uoFMmxln0GPXQ0AcCBXRq \n", + "1 spotify:track:1prYSRBfwPvE3v8jSRZL3Q \n", + "2 spotify:track:6MPpnJDLk37GEIM0iGGITd \n", + "3 spotify:track:5DMItYJluCFc7YtFdP4aXo \n", + "4 spotify:track:2nMZx7QHerfo4Wv37xNUEC \n", + ".. ... \n", + "107 spotify:track:3AgiRs3oxc2dFh0CPUHXJs \n", + "108 spotify:track:1sEC3X76vXgpsgnfaXEMwR \n", + "109 spotify:track:5ASM6Qjiav2xPe7gRkQMsQ \n", + "110 spotify:track:5SyQ5OhqrkJGb35V7RBoL0 \n", + "111 spotify:track:6Lv9ozIdb06duB01e6ZpNQ \n", + "\n", + " track_href \\\n", + "0 https://api.spotify.com/v1/tracks/7uoFMmxln0GP... \n", + "1 https://api.spotify.com/v1/tracks/1prYSRBfwPvE... \n", + "2 https://api.spotify.com/v1/tracks/6MPpnJDLk37G... \n", + "3 https://api.spotify.com/v1/tracks/5DMItYJluCFc... \n", + "4 https://api.spotify.com/v1/tracks/2nMZx7QHerfo... \n", + ".. ... \n", + "107 https://api.spotify.com/v1/tracks/3AgiRs3oxc2d... \n", + "108 https://api.spotify.com/v1/tracks/1sEC3X76vXgp... \n", + "109 https://api.spotify.com/v1/tracks/5ASM6Qjiav2x... \n", + "110 https://api.spotify.com/v1/tracks/5SyQ5OhqrkJG... \n", + "111 https://api.spotify.com/v1/tracks/6Lv9ozIdb06d... \n", + "\n", + " analysis_url duration_ms \\\n", + "0 https://api.spotify.com/v1/audio-analysis/7uoF... 165907 \n", + "1 https://api.spotify.com/v1/audio-analysis/1prY... 117587 \n", + "2 https://api.spotify.com/v1/audio-analysis/6MPp... 133773 \n", + "3 https://api.spotify.com/v1/audio-analysis/5DMI... 213160 \n", + "4 https://api.spotify.com/v1/audio-analysis/2nMZ... 216907 \n", + ".. ... ... \n", + "107 https://api.spotify.com/v1/audio-analysis/3Agi... 245333 \n", + "108 https://api.spotify.com/v1/audio-analysis/1sEC... 273573 \n", + "109 https://api.spotify.com/v1/audio-analysis/5ASM... 181267 \n", + "110 https://api.spotify.com/v1/audio-analysis/5SyQ... 252200 \n", + "111 https://api.spotify.com/v1/audio-analysis/6Lv9... 267227 \n", + "\n", + " time_signature \n", + "0 3 \n", + "1 4 \n", + "2 4 \n", + "3 3 \n", + "4 4 \n", + ".. ... \n", + "107 3 \n", + "108 3 \n", + "109 4 \n", + "110 4 \n", + "111 3 \n", + "\n", + "[112 rows x 20 columns]" + ] + }, + "execution_count": 118, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final_df_2" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "id": "39eb38cd-2828-4658-86f6-2570a7cbf2ec", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(Index(['id', 'name', 'artist', 'danceability', 'energy', 'key', 'loudness',\n", + " 'mode', 'speechiness', 'acousticness', 'instrumentalness', 'liveness',\n", + " 'valence', 'tempo', 'type', 'uri', 'track_href', 'analysis_url',\n", + " 'duration_ms', 'time_signature'],\n", + " dtype='object'),\n", + " Index(['id', 'album', 'name', 'artist', 'explicit', 'popularity',\n", + " 'danceability', 'energy', 'key', 'loudness', 'mode', 'speechiness',\n", + " 'acousticness', 'instrumentalness', 'liveness', 'valence', 'tempo',\n", + " 'type', 'uri', 'track_href', 'analysis_url', 'duration_ms',\n", + " 'time_signature'],\n", + " dtype='object'))" + ] + }, + "execution_count": 119, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final_df_2.columns, final_df.columns" + ] + }, + { + "cell_type": "markdown", + "id": "1a9ea2bc-2f74-4a4d-a8ae-26bb8eac67f3", + "metadata": {}, + "source": [ + "--> final_df_2 is missing 3 columns in comparison: album, explicit, polularity" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "24b25dd2-747c-4a57-b9da-7af9db585548", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}