{ "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.4-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." ], "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" ] }, { "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