{ "metadata": { "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.8.6-final" }, "orig_nbformat": 2, "kernelspec": { "name": "python3", "display_name": "Python 3", "language": "python" } }, "nbformat": 4, "nbformat_minor": 2, "cells": [ { "source": [ "# Listening Analysis\n", "\n", "Combining Spotify & Last.fm data for exploring habits and trends\n", "Uses two data sources,\n", "\n", "1. Last.fm scrobbles\n", "2. Spotify audio features\n", "\n", "The two are joined by searching Last.fm tracks on Spotify to get a Uri, the track name and artist name are provided for the query.\n", "These Uris can be used to retrieve Spotify feature descriptors. `all_joined()` gets a BigQuery of that joins the scrobble time series with their audio features and provides this as a panda frame.\n", "\n", "Explorations are made from [album](./album.ipynb), [artist](./artist.ipynb) and [playlist](./playlist.ipynb) perspectives. " ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "track object\n", "album object\n", "artist object\n", "uri object\n", "acousticness float64\n", "danceability float64\n", "duration_ms int64\n", "energy float64\n", "instrumentalness float64\n", "key int64\n", "liveness float64\n", "loudness float64\n", "mode int64\n", "speechiness float64\n", "tempo float64\n", "time_signature int64\n", "valence float64\n", "dtype: object" ] }, "metadata": {}, "execution_count": 3 } ], "source": [ "scrobbles.dtypes" ] }, { "source": [ "# Spotify Descriptor\n", "\n", "The Spotify API provides access to various characteristics about a track, they are used here for exploring listening habits. The descriptions from the [Spotify API Documentation](https://developer.spotify.com/documentation/web-api/reference/#object-audiofeaturesobject) can be seen below:\n", "\n", "### acousticness\n", "A confidence measure from 0.0 to 1.0 of whether the track is acoustic. 1.0 represents high confidence the track is acoustic.\n", "\n", "### danceability\n", "Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.\n", "\n", "### energy\n", "Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute include dynamic range, perceived loudness, timbre, onset rate, and general entropy.\n", "\n", "### instrumentalness\n", "Predicts whether a track contains no vocals. “Ooh” and “aah” sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly “vocal”. The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0.\n", "\n", "### key\n", "The key the track is in. Integers map to pitches using standard Pitch Class notation . E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on.\n", "\n", "### liveness\n", "Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihood that the track is live. \tFloat\n", "\n", "### loudness\n", "The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks. Loudness is the quality of a sound that is the primary psychological correlate of physical strength (amplitude). Values typical range between -60 and 0 db.\n", "\n", "### mode\n", "Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0.\n", "\n", "### speechiness\n", "Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, either in sections or layered, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks.\n", "\n", "### tempo\n", "The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration.\n", "\n", "### time_signature\n", "An estimated overall time signature of a track. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure).\n", "\n", "### valence\n", "A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry)." ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 4, "metadata": { "tags": [] }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " acousticness danceability duration_ms energy instrumentalness \\\n", "mean 0.170649 0.589141 2.422924e+05 0.711968 0.213591 \n", "std 0.246679 0.173905 1.220714e+05 0.204289 0.335353 \n", "min 0.000000 0.000000 1.578700e+04 0.000000 0.000000 \n", "25% 0.004320 0.470000 1.893220e+05 0.586000 0.000000 \n", "50% 0.045500 0.599000 2.264410e+05 0.749000 0.001100 \n", "75% 0.237000 0.724000 2.787440e+05 0.878000 0.394000 \n", "max 0.996000 0.981000 4.995315e+06 0.999000 0.995000 \n", "\n", " key liveness loudness mode speechiness tempo \\\n", "mean 5.328584 0.216903 -7.127309 0.581856 0.146982 124.640429 \n", "std 3.673929 0.173524 3.646891 0.493257 0.136440 30.809049 \n", "min 0.000000 0.000000 -60.000000 0.000000 0.000000 0.000000 \n", "25% 2.000000 0.099900 -8.590000 0.000000 0.047500 97.805000 \n", "50% 6.000000 0.141000 -6.472000 1.000000 0.080800 124.992000 \n", "75% 9.000000 0.300000 -4.827000 1.000000 0.223000 143.188000 \n", "max 11.000000 0.995000 3.108000 1.000000 0.966000 248.028000 \n", "\n", " time_signature valence \n", "mean 3.957806 0.418024 \n", "std 0.356726 0.236941 \n", "min 0.000000 0.000000 \n", "25% 4.000000 0.221000 \n", "50% 4.000000 0.398000 \n", "75% 4.000000 0.597000 \n", "max 5.000000 0.983000 " ], "text/html": "
\n | acousticness | \ndanceability | \nduration_ms | \nenergy | \ninstrumentalness | \nkey | \nliveness | \nloudness | \nmode | \nspeechiness | \ntempo | \ntime_signature | \nvalence | \n
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mean | \n0.170649 | \n0.589141 | \n2.422924e+05 | \n0.711968 | \n0.213591 | \n5.328584 | \n0.216903 | \n-7.127309 | \n0.581856 | \n0.146982 | \n124.640429 | \n3.957806 | \n0.418024 | \n
std | \n0.246679 | \n0.173905 | \n1.220714e+05 | \n0.204289 | \n0.335353 | \n3.673929 | \n0.173524 | \n3.646891 | \n0.493257 | \n0.136440 | \n30.809049 | \n0.356726 | \n0.236941 | \n
min | \n0.000000 | \n0.000000 | \n1.578700e+04 | \n0.000000 | \n0.000000 | \n0.000000 | \n0.000000 | \n-60.000000 | \n0.000000 | \n0.000000 | \n0.000000 | \n0.000000 | \n0.000000 | \n
25% | \n0.004320 | \n0.470000 | \n1.893220e+05 | \n0.586000 | \n0.000000 | \n2.000000 | \n0.099900 | \n-8.590000 | \n0.000000 | \n0.047500 | \n97.805000 | \n4.000000 | \n0.221000 | \n
50% | \n0.045500 | \n0.599000 | \n2.264410e+05 | \n0.749000 | \n0.001100 | \n6.000000 | \n0.141000 | \n-6.472000 | \n1.000000 | \n0.080800 | \n124.992000 | \n4.000000 | \n0.398000 | \n
75% | \n0.237000 | \n0.724000 | \n2.787440e+05 | \n0.878000 | \n0.394000 | \n9.000000 | \n0.300000 | \n-4.827000 | \n1.000000 | \n0.223000 | \n143.188000 | \n4.000000 | \n0.597000 | \n
max | \n0.996000 | \n0.981000 | \n4.995315e+06 | \n0.999000 | \n0.995000 | \n11.000000 | \n0.995000 | \n3.108000 | \n1.000000 | \n0.966000 | \n248.028000 | \n5.000000 | \n0.983000 | \n
\n | track | \nalbum | \nartist | \nuri | \nacousticness | \ndanceability | \nduration_ms | \nenergy | \ninstrumentalness | \nkey | \nliveness | \nloudness | \nmode | \nspeechiness | \ntempo | \ntime_signature | \nvalence | \n
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
time | \n\n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n | \n |
2020-12-31 18:35:28+00:00 | \nBlackbird - Gorgon City Remix | \nBlackbird EP | \nJoeski | \nspotify:track:3eGyeq8R8PscX1d13c9eJP | \n0.000542 | \n0.803 | \n389834 | \n0.857 | \n0.840 | \n4 | \n0.0787 | \n-7.273 | \n0 | \n0.0449 | \n125.016 | \n4 | \n0.2230 | \n
2020-12-31 18:28:13+00:00 | \nLanterns - Dead Man's Chest Remix | \nLanterns / Lanterns (Dead Man's Chest Remix) | \nTim Reaper | \nspotify:track:3lc7wN7T29s7uRbPZR0hTH | \n0.001530 | \n0.537 | \n440255 | \n0.868 | \n0.877 | \n10 | \n0.5730 | \n-7.319 | \n0 | \n0.0618 | \n157.015 | \n4 | \n0.2650 | \n
2020-12-31 18:22:07+00:00 | \nID Check - Original Mix | \nToolroom Ibiza 2019 | \nBen A | \nspotify:track:4x94xmQhUnd59k8oGM7AkG | \n0.001720 | \n0.809 | \n372614 | \n0.982 | \n0.911 | \n6 | \n0.0657 | \n-8.690 | \n0 | \n0.0460 | \n123.992 | \n4 | \n0.8240 | \n
2020-12-31 17:52:23+00:00 | \nUp & Down | \nEmotion EP | \nPurple Disco Machine | \nspotify:track:11DRarpv190YnCAXt85uFA | \n0.032000 | \n0.758 | \n409961 | \n0.913 | \n0.739 | \n5 | \n0.0304 | \n-6.712 | \n1 | \n0.0518 | \n117.997 | \n4 | \n0.7230 | \n
2020-12-31 17:00:28+00:00 | \nCuatro | \nTomahawk EP | \nMystic State | \nspotify:track:6JBKvAWsMvo68a9pMa9Ujn | \n0.040300 | \n0.621 | \n342866 | \n0.680 | \n0.803 | \n9 | \n0.2890 | \n-10.943 | \n0 | \n0.0484 | \n139.989 | \n4 | \n0.2190 | \n
... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n... | \n
2017-11-03 03:35:27+00:00 | \nJulia | \nVoid | \nRL Grime | \nspotify:track:4or82pWT9zvQNIoGckZiYb | \n0.003340 | \n0.573 | \n301429 | \n0.932 | \n0.744 | \n9 | \n0.1120 | \n-5.158 | \n0 | \n0.0500 | \n168.008 | \n4 | \n0.1610 | \n
2017-11-03 03:28:51+00:00 | \nSite Zero / The Vault | \nVoid | \nRL Grime | \nspotify:track:762ME2OHjuGo4xTbfZhpok | \n0.683000 | \n0.289 | \n464015 | \n0.404 | \n0.854 | \n7 | \n0.3280 | \n-12.815 | \n0 | \n0.0352 | \n92.873 | \n4 | \n0.0285 | \n
2017-11-03 02:54:37+00:00 | \nReminder (feat. How To Dress Well) | \nVoid | \nRL Grime | \nspotify:track:2JUdMBlA5JzuemLGzZNDrf | \n0.683000 | \n0.593 | \n260075 | \n0.560 | \n0.109 | \n3 | \n0.1040 | \n-7.059 | \n0 | \n0.0447 | \n113.895 | \n4 | \n0.3630 | \n
2017-11-03 02:50:23+00:00 | \nMonsoon | \nVoid | \nRL Grime | \nspotify:track:0jYAtTuRsRdHMuvaOXIAj5 | \n0.034600 | \n0.546 | \n254815 | \n0.850 | \n0.680 | \n10 | \n0.1120 | \n-3.366 | \n0 | \n0.0386 | \n161.996 | \n4 | \n0.3020 | \n
2017-11-03 02:43:01+00:00 | \nLet Go (interlude) | \nVoid | \nRL Grime | \nspotify:track:39FvWuHBtYQTJNdisJxZIG | \n0.181000 | \n0.361 | \n153346 | \n0.727 | \n0.710 | \n7 | \n0.1980 | \n-8.480 | \n1 | \n0.0519 | \n104.380 | \n4 | \n0.0368 | \n
92217 rows × 17 columns
\n