{ "cells": [ { "cell_type": "markdown", "metadata": {}, "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": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "track object\n", "album object\n", "artist object\n", "uri object\n", "acousticness float64\n", "danceability float64\n", "duration_ms float64\n", "energy float64\n", "instrumentalness float64\n", "key float64\n", "liveness float64\n", "loudness float64\n", "mode float64\n", "speechiness float64\n", "tempo float64\n", "time_signature float64\n", "valence float64\n", "dtype: object" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scrobbles.dtypes" ] }, { "cell_type": "markdown", "metadata": {}, "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": "code", "execution_count": 4, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", " | acousticness | \n", "danceability | \n", "duration_ms | \n", "energy | \n", "instrumentalness | \n", "key | \n", "liveness | \n", "loudness | \n", "mode | \n", "speechiness | \n", "tempo | \n", "time_signature | \n", "valence | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mean | \n", "0.178143 | \n", "0.589393 | \n", "2.430387e+05 | \n", "0.704151 | \n", "0.238050 | \n", "5.323999 | \n", "0.212907 | \n", "-7.321487 | \n", "0.570426 | \n", "0.144195 | \n", "124.301787 | \n", "3.954734 | \n", "0.416501 | \n", "
std | \n", "0.254707 | \n", "0.173309 | \n", "1.251593e+05 | \n", "0.210795 | \n", "0.349545 | \n", "3.673897 | \n", "0.170618 | \n", "3.805300 | \n", "0.495018 | \n", "0.135663 | \n", "30.824885 | \n", "0.370057 | \n", "0.238092 | \n", "
min | \n", "0.000000 | \n", "0.000000 | \n", "2.982700e+04 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "-60.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "
25% | \n", "0.004340 | \n", "0.472000 | \n", "1.875410e+05 | \n", "0.576000 | \n", "0.000001 | \n", "2.000000 | \n", "0.099100 | \n", "-8.837000 | \n", "0.000000 | \n", "0.047100 | \n", "97.215000 | \n", "4.000000 | \n", "0.218000 | \n", "
50% | \n", "0.047300 | \n", "0.601000 | \n", "2.266320e+05 | \n", "0.742000 | \n", "0.002100 | \n", "6.000000 | \n", "0.139000 | \n", "-6.617000 | \n", "1.000000 | \n", "0.078400 | \n", "124.985000 | \n", "4.000000 | \n", "0.396000 | \n", "
75% | \n", "0.250000 | \n", "0.722000 | \n", "2.822180e+05 | \n", "0.874000 | \n", "0.528000 | \n", "9.000000 | \n", "0.292000 | \n", "-4.890000 | \n", "1.000000 | \n", "0.216000 | \n", "142.899000 | \n", "4.000000 | \n", "0.596000 | \n", "
max | \n", "0.996000 | \n", "0.979000 | \n", "4.995315e+06 | \n", "0.999000 | \n", "0.995000 | \n", "11.000000 | \n", "0.995000 | \n", "3.108000 | \n", "1.000000 | \n", "0.966000 | \n", "248.028000 | \n", "5.000000 | \n", "0.988000 | \n", "
\n", " | track | \n", "album | \n", "artist | \n", "uri | \n", "acousticness | \n", "danceability | \n", "duration_ms | \n", "energy | \n", "instrumentalness | \n", "key | \n", "liveness | \n", "loudness | \n", "mode | \n", "speechiness | \n", "tempo | \n", "time_signature | \n", "valence | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
time | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2021-05-06 22:22:59+00:00 | \n", "The Enemy (feat. Fat Joe) | \n", "The Big Picture | \n", "Big L | \n", "spotify:track:27GWWBegMtuzYixG9JTNrW | \n", "0.11500 | \n", "0.600 | \n", "168013.0 | \n", "0.649 | \n", "0.000190 | \n", "11.0 | \n", "0.8240 | \n", "-8.372 | \n", "1.0 | \n", "0.3930 | \n", "174.130 | \n", "4.0 | \n", "0.8770 | \n", "
2021-05-06 22:21:00+00:00 | \n", "Running Up Freestyle | \n", "Fever | \n", "Megan Thee Stallion | \n", "spotify:track:1YU0fHUCpUyxkWqxx9ivHK | \n", "0.00825 | \n", "0.917 | \n", "124803.0 | \n", "0.897 | \n", "0.000000 | \n", "10.0 | \n", "0.2390 | \n", "-2.297 | \n", "0.0 | \n", "0.1190 | \n", "92.975 | \n", "4.0 | \n", "0.3100 | \n", "
2021-05-06 22:15:15+00:00 | \n", "m.A.A.d city | \n", "good kid, m.A.A.d city (Deluxe) | \n", "Kendrick Lamar | \n", "spotify:track:3qX1dqmDdmMvvfMVfsx4Bh | \n", "0.05380 | \n", "0.487 | \n", "350120.0 | \n", "0.729 | \n", "0.000004 | \n", "2.0 | \n", "0.4400 | \n", "-6.815 | \n", "1.0 | \n", "0.2710 | \n", "91.048 | \n", "4.0 | \n", "0.2170 | \n", "
2021-05-06 22:12:13+00:00 | \n", "Pony | \n", "House Party | \n", "Valentino Khan | \n", "spotify:track:26AIHH0JMIP8sd7YBM5uWb | \n", "0.00027 | \n", "0.803 | \n", "210937.0 | \n", "0.984 | \n", "0.846000 | \n", "1.0 | \n", "0.0434 | \n", "-3.930 | \n", "1.0 | \n", "0.0548 | \n", "127.994 | \n", "4.0 | \n", "0.3710 | \n", "
2021-05-06 22:07:57+00:00 | \n", "Pull The Trigga | \n", "UKF Bass Culture 4 | \n", "Dommix | \n", "spotify:track:0A0NjGXyHELTlBeMZcMyxZ | \n", "0.00825 | \n", "0.789 | \n", "260930.0 | \n", "0.891 | \n", "0.798000 | \n", "9.0 | \n", "0.8610 | \n", "-5.975 | \n", "1.0 | \n", "0.1030 | \n", "129.029 | \n", "4.0 | \n", "0.4100 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2017-11-03 03:28:51+00:00 | \n", "Site Zero / The Vault | \n", "Void | \n", "RL Grime | \n", "spotify:track:762ME2OHjuGo4xTbfZhpok | \n", "0.68300 | \n", "0.289 | \n", "464015.0 | \n", "0.404 | \n", "0.854000 | \n", "7.0 | \n", "0.3280 | \n", "-12.815 | \n", "0.0 | \n", "0.0352 | \n", "92.873 | \n", "4.0 | \n", "0.0285 | \n", "
2017-11-03 02:54:37+00:00 | \n", "Reminder (feat. How To Dress Well) | \n", "Void | \n", "RL Grime | \n", "spotify:track:2JUdMBlA5JzuemLGzZNDrf | \n", "0.68300 | \n", "0.593 | \n", "260075.0 | \n", "0.560 | \n", "0.109000 | \n", "3.0 | \n", "0.1040 | \n", "-7.059 | \n", "0.0 | \n", "0.0447 | \n", "113.895 | \n", "4.0 | \n", "0.3630 | \n", "
2017-11-03 02:50:23+00:00 | \n", "Monsoon | \n", "Void | \n", "RL Grime | \n", "spotify:track:0jYAtTuRsRdHMuvaOXIAj5 | \n", "0.03460 | \n", "0.546 | \n", "254815.0 | \n", "0.850 | \n", "0.680000 | \n", "10.0 | \n", "0.1120 | \n", "-3.366 | \n", "0.0 | \n", "0.0386 | \n", "161.996 | \n", "4.0 | \n", "0.3020 | \n", "
2017-11-03 02:46:26+00:00 | \n", "Core - Original Mix | \n", "Void | \n", "RL Grime | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
2017-11-03 02:43:01+00:00 | \n", "Let Go (interlude) | \n", "Void | \n", "RL Grime | \n", "spotify:track:39FvWuHBtYQTJNdisJxZIG | \n", "0.18100 | \n", "0.361 | \n", "153346.0 | \n", "0.727 | \n", "0.710000 | \n", "7.0 | \n", "0.1980 | \n", "-8.480 | \n", "1.0 | \n", "0.0519 | \n", "104.380 | \n", "4.0 | \n", "0.0368 | \n", "
94847 rows × 17 columns
\n", "