2021-02-01 01:37:22 +00:00
{
"cells": [
{
2021-02-20 00:16:03 +00:00
"cell_type": "markdown",
"metadata": {},
2021-02-01 01:37:22 +00:00
"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",
2021-02-04 13:34:25 +00:00
"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. "
2021-02-20 00:16:03 +00:00
]
2021-02-01 01:37:22 +00:00
},
{
"cell_type": "code",
2021-02-01 21:43:27 +00:00
"execution_count": 3,
2021-02-01 01:37:22 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"track object\n",
"album object\n",
"artist object\n",
"uri object\n",
"acousticness float64\n",
"danceability float64\n",
2021-02-20 00:16:03 +00:00
"duration_ms float64\n",
2021-02-01 01:37:22 +00:00
"energy float64\n",
"instrumentalness float64\n",
2021-02-20 00:16:03 +00:00
"key float64\n",
2021-02-01 01:37:22 +00:00
"liveness float64\n",
"loudness float64\n",
2021-02-20 00:16:03 +00:00
"mode float64\n",
2021-02-01 01:37:22 +00:00
"speechiness float64\n",
"tempo float64\n",
2021-02-20 00:16:03 +00:00
"time_signature float64\n",
2021-02-01 01:37:22 +00:00
"valence float64\n",
"dtype: object"
]
},
2021-02-20 00:16:03 +00:00
"execution_count": 3,
2021-02-01 01:37:22 +00:00
"metadata": {},
2021-02-20 00:16:03 +00:00
"output_type": "execute_result"
2021-02-01 01:37:22 +00:00
}
],
"source": [
"scrobbles.dtypes"
]
},
2021-02-04 13:34:25 +00:00
{
2021-02-20 00:16:03 +00:00
"cell_type": "markdown",
"metadata": {},
2021-02-04 13:34:25 +00:00
"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)."
2021-02-20 00:16:03 +00:00
]
2021-02-04 13:34:25 +00:00
},
2021-02-01 01:37:22 +00:00
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2021-02-20 00:16:03 +00:00
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>acousticness</th>\n",
" <th>danceability</th>\n",
" <th>duration_ms</th>\n",
" <th>energy</th>\n",
" <th>instrumentalness</th>\n",
" <th>key</th>\n",
" <th>liveness</th>\n",
" <th>loudness</th>\n",
" <th>mode</th>\n",
" <th>speechiness</th>\n",
" <th>tempo</th>\n",
" <th>time_signature</th>\n",
" <th>valence</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>0.173747</td>\n",
" <td>0.587779</td>\n",
" <td>2.434140e+05</td>\n",
" <td>0.708868</td>\n",
" <td>0.221769</td>\n",
" <td>5.323613</td>\n",
" <td>0.215247</td>\n",
" <td>-7.192452</td>\n",
" <td>0.574945</td>\n",
" <td>0.146165</td>\n",
" <td>124.368066</td>\n",
" <td>3.956350</td>\n",
" <td>0.416513</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>0.249600</td>\n",
" <td>0.174431</td>\n",
" <td>1.261789e+05</td>\n",
" <td>0.206463</td>\n",
" <td>0.340169</td>\n",
" <td>3.671363</td>\n",
" <td>0.172181</td>\n",
" <td>3.700907</td>\n",
" <td>0.494354</td>\n",
" <td>0.136497</td>\n",
" <td>30.753711</td>\n",
" <td>0.366894</td>\n",
" <td>0.236866</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>1.578700e+04</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>-60.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>0.004270</td>\n",
" <td>0.469000</td>\n",
" <td>1.887640e+05</td>\n",
" <td>0.581000</td>\n",
" <td>0.000000</td>\n",
" <td>2.000000</td>\n",
" <td>0.100000</td>\n",
" <td>-8.716000</td>\n",
" <td>0.000000</td>\n",
" <td>0.047400</td>\n",
" <td>97.530000</td>\n",
" <td>4.000000</td>\n",
" <td>0.220000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>0.046600</td>\n",
" <td>0.599000</td>\n",
" <td>2.269130e+05</td>\n",
" <td>0.745000</td>\n",
" <td>0.001310</td>\n",
" <td>6.000000</td>\n",
" <td>0.140000</td>\n",
" <td>-6.531000</td>\n",
" <td>1.000000</td>\n",
" <td>0.080100</td>\n",
" <td>124.984000</td>\n",
" <td>4.000000</td>\n",
" <td>0.396000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>0.244000</td>\n",
" <td>0.722000</td>\n",
" <td>2.807580e+05</td>\n",
" <td>0.876000</td>\n",
" <td>0.444000</td>\n",
" <td>9.000000</td>\n",
" <td>0.296000</td>\n",
" <td>-4.840000</td>\n",
" <td>1.000000</td>\n",
" <td>0.221000</td>\n",
" <td>143.012000</td>\n",
" <td>4.000000</td>\n",
" <td>0.595000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>0.996000</td>\n",
" <td>0.981000</td>\n",
" <td>4.995315e+06</td>\n",
" <td>0.999000</td>\n",
" <td>0.995000</td>\n",
" <td>11.000000</td>\n",
" <td>0.995000</td>\n",
" <td>3.108000</td>\n",
" <td>1.000000</td>\n",
" <td>0.966000</td>\n",
" <td>248.028000</td>\n",
" <td>5.000000</td>\n",
" <td>0.983000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
2021-02-01 01:37:22 +00:00
"text/plain": [
" acousticness danceability duration_ms energy instrumentalness \\\n",
2021-02-20 00:16:03 +00:00
"mean 0.173747 0.587779 2.434140e+05 0.708868 0.221769 \n",
"std 0.249600 0.174431 1.261789e+05 0.206463 0.340169 \n",
2021-02-01 01:37:22 +00:00
"min 0.000000 0.000000 1.578700e+04 0.000000 0.000000 \n",
2021-02-20 00:16:03 +00:00
"25% 0.004270 0.469000 1.887640e+05 0.581000 0.000000 \n",
"50% 0.046600 0.599000 2.269130e+05 0.745000 0.001310 \n",
"75% 0.244000 0.722000 2.807580e+05 0.876000 0.444000 \n",
2021-02-01 01:37:22 +00:00
"max 0.996000 0.981000 4.995315e+06 0.999000 0.995000 \n",
"\n",
" key liveness loudness mode speechiness tempo \\\n",
2021-02-20 00:16:03 +00:00
"mean 5.323613 0.215247 -7.192452 0.574945 0.146165 124.368066 \n",
"std 3.671363 0.172181 3.700907 0.494354 0.136497 30.753711 \n",
2021-02-01 01:37:22 +00:00
"min 0.000000 0.000000 -60.000000 0.000000 0.000000 0.000000 \n",
2021-02-20 00:16:03 +00:00
"25% 2.000000 0.100000 -8.716000 0.000000 0.047400 97.530000 \n",
"50% 6.000000 0.140000 -6.531000 1.000000 0.080100 124.984000 \n",
"75% 9.000000 0.296000 -4.840000 1.000000 0.221000 143.012000 \n",
2021-02-01 01:37:22 +00:00
"max 11.000000 0.995000 3.108000 1.000000 0.966000 248.028000 \n",
"\n",
" time_signature valence \n",
2021-02-20 00:16:03 +00:00
"mean 3.956350 0.416513 \n",
"std 0.366894 0.236866 \n",
2021-02-01 01:37:22 +00:00
"min 0.000000 0.000000 \n",
2021-02-20 00:16:03 +00:00
"25% 4.000000 0.220000 \n",
"50% 4.000000 0.396000 \n",
"75% 4.000000 0.595000 \n",
2021-02-01 01:37:22 +00:00
"max 5.000000 0.983000 "
2021-02-20 00:16:03 +00:00
]
2021-02-01 01:37:22 +00:00
},
2021-02-20 00:16:03 +00:00
"execution_count": 4,
2021-02-01 01:37:22 +00:00
"metadata": {},
2021-02-20 00:16:03 +00:00
"output_type": "execute_result"
2021-02-01 01:37:22 +00:00
}
],
"source": [
"scrobbles.describe()[1:]"
]
},
{
"cell_type": "code",
2021-02-01 21:43:27 +00:00
"execution_count": 5,
2021-02-01 01:37:22 +00:00
"metadata": {},
"outputs": [
{
"data": {
2021-02-20 00:16:03 +00:00
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>track</th>\n",
" <th>album</th>\n",
" <th>artist</th>\n",
" <th>uri</th>\n",
" <th>acousticness</th>\n",
" <th>danceability</th>\n",
" <th>duration_ms</th>\n",
" <th>energy</th>\n",
" <th>instrumentalness</th>\n",
" <th>key</th>\n",
" <th>liveness</th>\n",
" <th>loudness</th>\n",
" <th>mode</th>\n",
" <th>speechiness</th>\n",
" <th>tempo</th>\n",
" <th>time_signature</th>\n",
" <th>valence</th>\n",
" </tr>\n",
" <tr>\n",
" <th>time</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2020-12-31 18:35:28+00:00</th>\n",
" <td>Blackbird - Gorgon City Remix</td>\n",
" <td>Blackbird EP</td>\n",
" <td>Joeski</td>\n",
" <td>spotify:track:3eGyeq8R8PscX1d13c9eJP</td>\n",
" <td>0.000542</td>\n",
" <td>0.803</td>\n",
" <td>389834.0</td>\n",
" <td>0.857</td>\n",
" <td>0.840</td>\n",
" <td>4.0</td>\n",
" <td>0.0787</td>\n",
" <td>-7.273</td>\n",
" <td>0.0</td>\n",
" <td>0.0449</td>\n",
" <td>125.016</td>\n",
" <td>4.0</td>\n",
" <td>0.2230</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-31 18:28:13+00:00</th>\n",
" <td>Lanterns - Dead Man's Chest Remix</td>\n",
" <td>Lanterns / Lanterns (Dead Man's Chest Remix)</td>\n",
" <td>Tim Reaper</td>\n",
" <td>spotify:track:3lc7wN7T29s7uRbPZR0hTH</td>\n",
" <td>0.001530</td>\n",
" <td>0.537</td>\n",
" <td>440255.0</td>\n",
" <td>0.868</td>\n",
" <td>0.877</td>\n",
" <td>10.0</td>\n",
" <td>0.5730</td>\n",
" <td>-7.319</td>\n",
" <td>0.0</td>\n",
" <td>0.0618</td>\n",
" <td>157.015</td>\n",
" <td>4.0</td>\n",
" <td>0.2650</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-31 18:22:07+00:00</th>\n",
" <td>ID Check - Original Mix</td>\n",
" <td>Toolroom Ibiza 2019</td>\n",
" <td>Ben A</td>\n",
" <td>spotify:track:4x94xmQhUnd59k8oGM7AkG</td>\n",
" <td>0.001720</td>\n",
" <td>0.809</td>\n",
" <td>372614.0</td>\n",
" <td>0.982</td>\n",
" <td>0.911</td>\n",
" <td>6.0</td>\n",
" <td>0.0657</td>\n",
" <td>-8.690</td>\n",
" <td>0.0</td>\n",
" <td>0.0460</td>\n",
" <td>123.992</td>\n",
" <td>4.0</td>\n",
" <td>0.8240</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-31 17:52:23+00:00</th>\n",
" <td>Up & Down</td>\n",
" <td>Emotion EP</td>\n",
" <td>Purple Disco Machine</td>\n",
" <td>spotify:track:11DRarpv190YnCAXt85uFA</td>\n",
" <td>0.032000</td>\n",
" <td>0.758</td>\n",
" <td>409961.0</td>\n",
" <td>0.913</td>\n",
" <td>0.739</td>\n",
" <td>5.0</td>\n",
" <td>0.0304</td>\n",
" <td>-6.712</td>\n",
" <td>1.0</td>\n",
" <td>0.0518</td>\n",
" <td>117.997</td>\n",
" <td>4.0</td>\n",
" <td>0.7230</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020-12-31 17:00:28+00:00</th>\n",
" <td>Cuatro</td>\n",
" <td>Tomahawk EP</td>\n",
" <td>Mystic State</td>\n",
" <td>spotify:track:6JBKvAWsMvo68a9pMa9Ujn</td>\n",
" <td>0.040300</td>\n",
" <td>0.621</td>\n",
" <td>342866.0</td>\n",
" <td>0.680</td>\n",
" <td>0.803</td>\n",
" <td>9.0</td>\n",
" <td>0.2890</td>\n",
" <td>-10.943</td>\n",
" <td>0.0</td>\n",
" <td>0.0484</td>\n",
" <td>139.989</td>\n",
" <td>4.0</td>\n",
" <td>0.2190</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2017-11-03 03:28:51+00:00</th>\n",
" <td>Site Zero / The Vault</td>\n",
" <td>Void</td>\n",
" <td>RL Grime</td>\n",
" <td>spotify:track:762ME2OHjuGo4xTbfZhpok</td>\n",
" <td>0.683000</td>\n",
" <td>0.289</td>\n",
" <td>464015.0</td>\n",
" <td>0.404</td>\n",
" <td>0.854</td>\n",
" <td>7.0</td>\n",
" <td>0.3280</td>\n",
" <td>-12.815</td>\n",
" <td>0.0</td>\n",
" <td>0.0352</td>\n",
" <td>92.873</td>\n",
" <td>4.0</td>\n",
" <td>0.0285</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2017-11-03 02:54:37+00:00</th>\n",
" <td>Reminder (feat. How To Dress Well)</td>\n",
" <td>Void</td>\n",
" <td>RL Grime</td>\n",
" <td>spotify:track:2JUdMBlA5JzuemLGzZNDrf</td>\n",
" <td>0.683000</td>\n",
" <td>0.593</td>\n",
" <td>260075.0</td>\n",
" <td>0.560</td>\n",
" <td>0.109</td>\n",
" <td>3.0</td>\n",
" <td>0.1040</td>\n",
" <td>-7.059</td>\n",
" <td>0.0</td>\n",
" <td>0.0447</td>\n",
" <td>113.895</td>\n",
" <td>4.0</td>\n",
" <td>0.3630</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2017-11-03 02:50:23+00:00</th>\n",
" <td>Monsoon</td>\n",
" <td>Void</td>\n",
" <td>RL Grime</td>\n",
" <td>spotify:track:0jYAtTuRsRdHMuvaOXIAj5</td>\n",
" <td>0.034600</td>\n",
" <td>0.546</td>\n",
" <td>254815.0</td>\n",
" <td>0.850</td>\n",
" <td>0.680</td>\n",
" <td>10.0</td>\n",
" <td>0.1120</td>\n",
" <td>-3.366</td>\n",
" <td>0.0</td>\n",
" <td>0.0386</td>\n",
" <td>161.996</td>\n",
" <td>4.0</td>\n",
" <td>0.3020</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2017-11-03 02:46:26+00:00</th>\n",
" <td>Core - Original Mix</td>\n",
" <td>Void</td>\n",
" <td>RL Grime</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2017-11-03 02:43:01+00:00</th>\n",
" <td>Let Go (interlude)</td>\n",
" <td>Void</td>\n",
" <td>RL Grime</td>\n",
" <td>spotify:track:39FvWuHBtYQTJNdisJxZIG</td>\n",
" <td>0.181000</td>\n",
" <td>0.361</td>\n",
" <td>153346.0</td>\n",
" <td>0.727</td>\n",
" <td>0.710</td>\n",
" <td>7.0</td>\n",
" <td>0.1980</td>\n",
" <td>-8.480</td>\n",
" <td>1.0</td>\n",
" <td>0.0519</td>\n",
" <td>104.380</td>\n",
" <td>4.0</td>\n",
" <td>0.0368</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>88068 rows × 17 columns</p>\n",
"</div>"
],
2021-02-01 01:37:22 +00:00
"text/plain": [
2021-02-01 21:43:27 +00:00
" track \\\n",
"time \n",
"2020-12-31 18:35:28+00:00 Blackbird - Gorgon City Remix \n",
"2020-12-31 18:28:13+00:00 Lanterns - Dead Man's Chest Remix \n",
"2020-12-31 18:22:07+00:00 ID Check - Original Mix \n",
"2020-12-31 17:52:23+00:00 Up & Down \n",
"2020-12-31 17:00:28+00:00 Cuatro \n",
"... ... \n",
"2017-11-03 03:28:51+00:00 Site Zero / The Vault \n",
"2017-11-03 02:54:37+00:00 Reminder (feat. How To Dress Well) \n",
"2017-11-03 02:50:23+00:00 Monsoon \n",
2021-02-20 00:16:03 +00:00
"2017-11-03 02:46:26+00:00 Core - Original Mix \n",
2021-02-01 21:43:27 +00:00
"2017-11-03 02:43:01+00:00 Let Go (interlude) \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-01 21:43:27 +00:00
" album \\\n",
"time \n",
"2020-12-31 18:35:28+00:00 Blackbird EP \n",
"2020-12-31 18:28:13+00:00 Lanterns / Lanterns (Dead Man's Chest Remix) \n",
"2020-12-31 18:22:07+00:00 Toolroom Ibiza 2019 \n",
"2020-12-31 17:52:23+00:00 Emotion EP \n",
"2020-12-31 17:00:28+00:00 Tomahawk EP \n",
"... ... \n",
"2017-11-03 03:28:51+00:00 Void \n",
"2017-11-03 02:54:37+00:00 Void \n",
"2017-11-03 02:50:23+00:00 Void \n",
2021-02-20 00:16:03 +00:00
"2017-11-03 02:46:26+00:00 Void \n",
2021-02-01 21:43:27 +00:00
"2017-11-03 02:43:01+00:00 Void \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-01 21:43:27 +00:00
" artist \\\n",
"time \n",
"2020-12-31 18:35:28+00:00 Joeski \n",
"2020-12-31 18:28:13+00:00 Tim Reaper \n",
"2020-12-31 18:22:07+00:00 Ben A \n",
"2020-12-31 17:52:23+00:00 Purple Disco Machine \n",
"2020-12-31 17:00:28+00:00 Mystic State \n",
"... ... \n",
"2017-11-03 03:28:51+00:00 RL Grime \n",
"2017-11-03 02:54:37+00:00 RL Grime \n",
"2017-11-03 02:50:23+00:00 RL Grime \n",
2021-02-20 00:16:03 +00:00
"2017-11-03 02:46:26+00:00 RL Grime \n",
2021-02-01 21:43:27 +00:00
"2017-11-03 02:43:01+00:00 RL Grime \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-01 21:43:27 +00:00
" uri acousticness \\\n",
"time \n",
"2020-12-31 18:35:28+00:00 spotify:track:3eGyeq8R8PscX1d13c9eJP 0.000542 \n",
"2020-12-31 18:28:13+00:00 spotify:track:3lc7wN7T29s7uRbPZR0hTH 0.001530 \n",
"2020-12-31 18:22:07+00:00 spotify:track:4x94xmQhUnd59k8oGM7AkG 0.001720 \n",
"2020-12-31 17:52:23+00:00 spotify:track:11DRarpv190YnCAXt85uFA 0.032000 \n",
"2020-12-31 17:00:28+00:00 spotify:track:6JBKvAWsMvo68a9pMa9Ujn 0.040300 \n",
"... ... ... \n",
"2017-11-03 03:28:51+00:00 spotify:track:762ME2OHjuGo4xTbfZhpok 0.683000 \n",
"2017-11-03 02:54:37+00:00 spotify:track:2JUdMBlA5JzuemLGzZNDrf 0.683000 \n",
"2017-11-03 02:50:23+00:00 spotify:track:0jYAtTuRsRdHMuvaOXIAj5 0.034600 \n",
2021-02-20 00:16:03 +00:00
"2017-11-03 02:46:26+00:00 NaN NaN \n",
2021-02-01 21:43:27 +00:00
"2017-11-03 02:43:01+00:00 spotify:track:39FvWuHBtYQTJNdisJxZIG 0.181000 \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-01 21:43:27 +00:00
" danceability duration_ms energy \\\n",
"time \n",
2021-02-20 00:16:03 +00:00
"2020-12-31 18:35:28+00:00 0.803 389834.0 0.857 \n",
"2020-12-31 18:28:13+00:00 0.537 440255.0 0.868 \n",
"2020-12-31 18:22:07+00:00 0.809 372614.0 0.982 \n",
"2020-12-31 17:52:23+00:00 0.758 409961.0 0.913 \n",
"2020-12-31 17:00:28+00:00 0.621 342866.0 0.680 \n",
2021-02-01 21:43:27 +00:00
"... ... ... ... \n",
2021-02-20 00:16:03 +00:00
"2017-11-03 03:28:51+00:00 0.289 464015.0 0.404 \n",
"2017-11-03 02:54:37+00:00 0.593 260075.0 0.560 \n",
"2017-11-03 02:50:23+00:00 0.546 254815.0 0.850 \n",
"2017-11-03 02:46:26+00:00 NaN NaN NaN \n",
"2017-11-03 02:43:01+00:00 0.361 153346.0 0.727 \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-20 00:16:03 +00:00
" instrumentalness key liveness loudness mode \\\n",
"time \n",
"2020-12-31 18:35:28+00:00 0.840 4.0 0.0787 -7.273 0.0 \n",
"2020-12-31 18:28:13+00:00 0.877 10.0 0.5730 -7.319 0.0 \n",
"2020-12-31 18:22:07+00:00 0.911 6.0 0.0657 -8.690 0.0 \n",
"2020-12-31 17:52:23+00:00 0.739 5.0 0.0304 -6.712 1.0 \n",
"2020-12-31 17:00:28+00:00 0.803 9.0 0.2890 -10.943 0.0 \n",
"... ... ... ... ... ... \n",
"2017-11-03 03:28:51+00:00 0.854 7.0 0.3280 -12.815 0.0 \n",
"2017-11-03 02:54:37+00:00 0.109 3.0 0.1040 -7.059 0.0 \n",
"2017-11-03 02:50:23+00:00 0.680 10.0 0.1120 -3.366 0.0 \n",
"2017-11-03 02:46:26+00:00 NaN NaN NaN NaN NaN \n",
"2017-11-03 02:43:01+00:00 0.710 7.0 0.1980 -8.480 1.0 \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-01 21:43:27 +00:00
" speechiness tempo time_signature valence \n",
"time \n",
2021-02-20 00:16:03 +00:00
"2020-12-31 18:35:28+00:00 0.0449 125.016 4.0 0.2230 \n",
"2020-12-31 18:28:13+00:00 0.0618 157.015 4.0 0.2650 \n",
"2020-12-31 18:22:07+00:00 0.0460 123.992 4.0 0.8240 \n",
"2020-12-31 17:52:23+00:00 0.0518 117.997 4.0 0.7230 \n",
"2020-12-31 17:00:28+00:00 0.0484 139.989 4.0 0.2190 \n",
2021-02-01 21:43:27 +00:00
"... ... ... ... ... \n",
2021-02-20 00:16:03 +00:00
"2017-11-03 03:28:51+00:00 0.0352 92.873 4.0 0.0285 \n",
"2017-11-03 02:54:37+00:00 0.0447 113.895 4.0 0.3630 \n",
"2017-11-03 02:50:23+00:00 0.0386 161.996 4.0 0.3020 \n",
"2017-11-03 02:46:26+00:00 NaN NaN NaN NaN \n",
"2017-11-03 02:43:01+00:00 0.0519 104.380 4.0 0.0368 \n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-20 00:16:03 +00:00
"[88068 rows x 17 columns]"
]
2021-02-01 01:37:22 +00:00
},
2021-02-20 00:16:03 +00:00
"execution_count": 5,
2021-02-01 01:37:22 +00:00
"metadata": {},
2021-02-20 00:16:03 +00:00
"output_type": "execute_result"
2021-02-01 01:37:22 +00:00
}
],
"source": [
2021-02-01 21:43:27 +00:00
"scrobbles.sort_index(ascending=False)"
2021-02-01 01:37:22 +00:00
]
},
{
"cell_type": "markdown",
2021-02-20 00:16:03 +00:00
"metadata": {},
"source": [
"# What does my listening *\"palette\"* look like over time "
]
2021-02-01 01:37:22 +00:00
},
{
"cell_type": "code",
2021-02-20 00:16:03 +00:00
"execution_count": 6,
2021-02-01 01:37:22 +00:00
"metadata": {},
"outputs": [
{
"data": {
2021-02-20 00:16:03 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoEAAAHmCAYAAAAMSlTHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAABJ0AAASdAHeZh94AAEAAElEQVR4nOydd3gU1deA39n0hBASeu+999A7ItKkCBaKBaSoYMOuYPsh+ikWQAQUUBSkqHTpRXoLLXQILbQESO97vz/uJiQ7s8mmt/s+zz6bnLlz587u7O6ZUzUhBAqFQqFQKBSKwoUptxegUCgUCoVCoch5lBKoUCgUCoVCUQhRSqBCoVAoFApFIUQpgQqFQqFQKBSFEKUEKhQKhUKhUBRClBKoUCgUCoVCUQhRSqBCoVAoFApFIUQpgQqFQqFQKBSFEKUEKhQKhUKhUBRClBKoUCgUCoVCUQhRSqBCoVAoFApFIUQpgYo8g6ZpQtO07bm9joyiaVoVyzksyO21ZAWapm3XNE01F89CNE3rbLlGpmTT/FMs83fOjvkV6UN9hhR5HaUEKrIVyw9Stn8JFjQFLDvQNM1D07RJmqZt1TTtjqZ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VNtP49jbwRsH6tE9+jb9J4j7oYLCErrKy5TWbOX6FQSqAi/yCEuCCEmA90Qgbl90+2OdF1Yssytw/wtrgW8zpHLc/trTdomlaEZDFBaWGJS9uMdKG+mdZ4S5HfjFLD8rzCYFunTMx5Twix3c4591meH7Vz/gRSv2ZAZvnmCEKIeCHEYSHEFzyMiRuQbEha17kR6X1NEtcSIYTYKoR4DemudrZzjsRs7Rc0TUvthuU
"text/plain": [
"<Figure size 720x480 with 1 Axes>"
]
2021-02-01 01:37:22 +00:00
},
"metadata": {
"needs_background": "light"
2021-02-20 00:16:03 +00:00
},
"output_type": "display_data"
2021-02-01 01:37:22 +00:00
}
],
"source": [
2021-02-01 21:43:27 +00:00
"# select only descriptor float columns\n",
"filtered_scrobbles = scrobbles.loc[:, float_headers]\n",
"# resample by month and mean\n",
"filtered_scrobbles = filtered_scrobbles.resample(\"3W\").mean()\n",
"\n",
"# filtered_scrobbles[\"instrumentalness\"].plot()\n",
"filtered_scrobbles.plot(linewidth=3)\n",
"\n",
"plt.title(f'Listening Characteristics Over Time')\n",
"plt.legend(loc = \"upper right\", fontsize = \"xx-small\")\n",
"plt.ylim([0, 1])\n",
2021-02-01 01:37:22 +00:00
"plt.grid()\n",
"plt.show()"
]
},
{
2021-02-20 00:16:03 +00:00
"cell_type": "markdown",
"metadata": {},
2021-02-01 01:37:22 +00:00
"source": [
2021-02-20 00:16:03 +00:00
"# How much music do I listen to each day?"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAy4AAAHmCAYAAACVl9pbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAABJ0AAASdAHeZh94AAEAAElEQVR4nOydd3hcxb2w39mqbrl3sDG9GtMJTZQQahJSIb186clN7z256TchDRJSgIRACBAggYRuqgHbYNw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hufkicKEQ4hmsGi49WHVMLsOyJt2kbLt4oA0/FEIcP7AeKeX3B9Z/AqvWx3exsq89ixX3MQsr0Pw04NqB84w2fwHejuUWt2bAxSmIFVi+DDgK61qL4Wngg0KIM7ASKqTruPiAD6uJA6SUfxZCnIJVK2eLEOJhrDiSSVj1YM7DEjg+MugrzHLHQDuuxrrW+7Gu9c1Y17pA3VhKmRJC/Aqrjsvqge1DQNNA+xYP/O1ASimFEL/DEszA/v4YDAZDQRiLi8FgMBSAlPIGrID4F7AmsZ/FqmnxU+CsgRSy6vbrgIuxJqpXYbnHRLEEl5cG0YSHsYShGixh5XNYk9hHgXOllHcP4pi5uAGrwOB8rMD8TwJHDiw/Wc0uJqVcj6VJ34814f4eSjrdgYn5+QPHaCF7/5qwUkl/ZuA6Rp2BDFdvxGp/EKvNr8cqrvmJgc3cMpTlYhuW61k7lsDxViw3rculVnxyoA0fx3pnnsd6hz6LJVxMwHrfri/y/K4MXOtbsBIB+LCu72osweitHrt9A+vd68Ny+7oGK/vb6VgCVi5uwRL6+rHup8FgMBSFMFkIDQaDwWDIjxDiEuAR4EdSyq8UsP08LKHlVinle4e3deW
"text/plain": [
"<Figure size 960x480 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
2021-02-01 01:37:22 +00:00
],
2021-02-20 00:16:03 +00:00
"source": [
"by_day = scrobbles[\"duration_ms\"].sort_index(ascending=True)[\"2018\":].resample(\"1D\").sum()\n",
"\n",
"years = [2018, 2021]\n",
"\n",
"# hr, min, sec, ms\n",
"ms_per_day = 24 * 60 * 60 * 1000\n",
"ms_per_hour = 60 * 60 * 1000\n",
"\n",
"listening_proportion = by_day / ms_per_hour\n",
"\n",
"lobf = np.array([])\n",
"for year in range(*years):\n",
" \n",
" year_frame = listening_proportion[str(year)]\n",
" x = np.arange(0, len(year_frame))\n",
" poly = Polynomial.fit(x, year_frame.to_numpy(), 6)\n",
" lobf = np.append(lobf, poly(x))\n",
"\n",
"listening_proportion = listening_proportion.reset_index() # to allow column adding\n",
"listening_proportion[\"lobf\"] = lobf # add line of best fit data here to easily resample\n",
"listening_proportion = listening_proportion.set_index('time') # set index for plotting\n",
"\n",
"to_display = listening_proportion.resample(\"5D\").mean() # mean requires dropping the last datapoint later\n",
"\n",
"plt.figure(figsize=(8, 4))\n",
"ax = to_display[\"duration_ms\"].plot(lw=2) # plot main time series\n",
"\n",
"# PLOT line of best fit\n",
"for idx, year in enumerate(range(*years)):\n",
" to_display[\"lobf\"][str(year)][:-1].plot(lw=4)\n",
"\n",
"plt.title('Hours listening per day')\n",
"plt.ylabel(\"Hours/Day\")\n",
"# plt.ylim([0, 12])\n",
"plt.grid()"
]
},
{
2021-02-01 01:37:22 +00:00
"cell_type": "markdown",
2021-02-20 00:16:03 +00:00
"metadata": {},
"source": [
"# Imports & Setupto_numpy"
]
2021-02-01 01:37:22 +00:00
},
{
"cell_type": "code",
2021-02-03 16:08:06 +00:00
"execution_count": 1,
2021-02-01 01:37:22 +00:00
"metadata": {},
"outputs": [],
"source": [
2021-02-01 21:43:27 +00:00
"from datetime import datetime\n",
"\n",
2021-02-01 01:37:22 +00:00
"from google.cloud import bigquery\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
2021-02-01 21:43:27 +00:00
"mpl.rcParams['figure.dpi'] = 120\n",
2021-02-01 01:37:22 +00:00
"\n",
"from analysis.net import get_spotnet, get_playlist, track_frame\n",
"from analysis.query import *\n",
2021-02-01 21:43:27 +00:00
"from analysis import float_headers, days_since\n",
2021-02-01 01:37:22 +00:00
"\n",
2021-02-01 21:43:27 +00:00
"import numpy as np\n",
2021-02-20 00:16:03 +00:00
"from numpy.polynomial.polynomial import Polynomial\n",
2021-02-01 01:37:22 +00:00
"import pandas as pd\n",
"\n",
"client = bigquery.Client()\n",
"spotnet = get_spotnet()\n",
2021-02-01 21:43:27 +00:00
"cache = 'query.csv'\n",
"first_day = datetime(year=2017, month=11, day=3)"
2021-02-01 01:37:22 +00:00
]
},
{
2021-02-20 00:16:03 +00:00
"cell_type": "markdown",
"metadata": {},
2021-02-01 01:37:22 +00:00
"source": [
"## Read Scrobble Frame"
2021-02-20 00:16:03 +00:00
]
2021-02-01 01:37:22 +00:00
},
{
"cell_type": "code",
2021-02-03 16:08:06 +00:00
"execution_count": 2,
2021-02-01 01:37:22 +00:00
"metadata": {},
"outputs": [],
"source": [
2021-02-03 16:08:06 +00:00
"scrobbles = get_query(cache=cache)"
2021-02-01 01:37:22 +00:00
]
},
{
2021-02-20 00:16:03 +00:00
"cell_type": "markdown",
"metadata": {},
2021-02-01 01:37:22 +00:00
"source": [
"## Write Scrobble Frame"
2021-02-20 00:16:03 +00:00
]
2021-02-01 01:37:22 +00:00
},
{
"cell_type": "code",
2021-02-03 16:08:06 +00:00
"execution_count": 3,
2021-02-01 01:37:22 +00:00
"metadata": {},
"outputs": [],
"source": [
2021-02-03 16:08:06 +00:00
"scrobbles.reset_index().to_csv(cache, sep='\\t')"
2021-02-01 01:37:22 +00:00
]
}
2021-02-20 00:16:03 +00:00
],
"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.8.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}