{ "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.173747 | \n", "0.587779 | \n", "2.434140e+05 | \n", "0.708868 | \n", "0.221769 | \n", "5.323613 | \n", "0.215247 | \n", "-7.192452 | \n", "0.574945 | \n", "0.146165 | \n", "124.368066 | \n", "3.956350 | \n", "0.416513 | \n", "
std | \n", "0.249600 | \n", "0.174431 | \n", "1.261789e+05 | \n", "0.206463 | \n", "0.340169 | \n", "3.671363 | \n", "0.172181 | \n", "3.700907 | \n", "0.494354 | \n", "0.136497 | \n", "30.753711 | \n", "0.366894 | \n", "0.236866 | \n", "
min | \n", "0.000000 | \n", "0.000000 | \n", "1.578700e+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.004270 | \n", "0.469000 | \n", "1.887640e+05 | \n", "0.581000 | \n", "0.000000 | \n", "2.000000 | \n", "0.100000 | \n", "-8.716000 | \n", "0.000000 | \n", "0.047400 | \n", "97.530000 | \n", "4.000000 | \n", "0.220000 | \n", "
50% | \n", "0.046600 | \n", "0.599000 | \n", "2.269130e+05 | \n", "0.745000 | \n", "0.001310 | \n", "6.000000 | \n", "0.140000 | \n", "-6.531000 | \n", "1.000000 | \n", "0.080100 | \n", "124.984000 | \n", "4.000000 | \n", "0.396000 | \n", "
75% | \n", "0.244000 | \n", "0.722000 | \n", "2.807580e+05 | \n", "0.876000 | \n", "0.444000 | \n", "9.000000 | \n", "0.296000 | \n", "-4.840000 | \n", "1.000000 | \n", "0.221000 | \n", "143.012000 | \n", "4.000000 | \n", "0.595000 | \n", "
max | \n", "0.996000 | \n", "0.981000 | \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.983000 | \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", " |
2020-12-31 18:35:28+00:00 | \n", "Blackbird - Gorgon City Remix | \n", "Blackbird EP | \n", "Joeski | \n", "spotify:track:3eGyeq8R8PscX1d13c9eJP | \n", "0.000542 | \n", "0.803 | \n", "389834.0 | \n", "0.857 | \n", "0.840 | \n", "4.0 | \n", "0.0787 | \n", "-7.273 | \n", "0.0 | \n", "0.0449 | \n", "125.016 | \n", "4.0 | \n", "0.2230 | \n", "
2020-12-31 18:28:13+00:00 | \n", "Lanterns - Dead Man's Chest Remix | \n", "Lanterns / Lanterns (Dead Man's Chest Remix) | \n", "Tim Reaper | \n", "spotify:track:3lc7wN7T29s7uRbPZR0hTH | \n", "0.001530 | \n", "0.537 | \n", "440255.0 | \n", "0.868 | \n", "0.877 | \n", "10.0 | \n", "0.5730 | \n", "-7.319 | \n", "0.0 | \n", "0.0618 | \n", "157.015 | \n", "4.0 | \n", "0.2650 | \n", "
2020-12-31 18:22:07+00:00 | \n", "ID Check - Original Mix | \n", "Toolroom Ibiza 2019 | \n", "Ben A | \n", "spotify:track:4x94xmQhUnd59k8oGM7AkG | \n", "0.001720 | \n", "0.809 | \n", "372614.0 | \n", "0.982 | \n", "0.911 | \n", "6.0 | \n", "0.0657 | \n", "-8.690 | \n", "0.0 | \n", "0.0460 | \n", "123.992 | \n", "4.0 | \n", "0.8240 | \n", "
2020-12-31 17:52:23+00:00 | \n", "Up & Down | \n", "Emotion EP | \n", "Purple Disco Machine | \n", "spotify:track:11DRarpv190YnCAXt85uFA | \n", "0.032000 | \n", "0.758 | \n", "409961.0 | \n", "0.913 | \n", "0.739 | \n", "5.0 | \n", "0.0304 | \n", "-6.712 | \n", "1.0 | \n", "0.0518 | \n", "117.997 | \n", "4.0 | \n", "0.7230 | \n", "
2020-12-31 17:00:28+00:00 | \n", "Cuatro | \n", "Tomahawk EP | \n", "Mystic State | \n", "spotify:track:6JBKvAWsMvo68a9pMa9Ujn | \n", "0.040300 | \n", "0.621 | \n", "342866.0 | \n", "0.680 | \n", "0.803 | \n", "9.0 | \n", "0.2890 | \n", "-10.943 | \n", "0.0 | \n", "0.0484 | \n", "139.989 | \n", "4.0 | \n", "0.2190 | \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.683000 | \n", "0.289 | \n", "464015.0 | \n", "0.404 | \n", "0.854 | \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.683000 | \n", "0.593 | \n", "260075.0 | \n", "0.560 | \n", "0.109 | \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.034600 | \n", "0.546 | \n", "254815.0 | \n", "0.850 | \n", "0.680 | \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.181000 | \n", "0.361 | \n", "153346.0 | \n", "0.727 | \n", "0.710 | \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", "
88068 rows × 17 columns
\n", "