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",
2021-03-10 20:01:13 +00:00
"execution_count": 16,
2021-02-20 00:16:03 +00:00
"metadata": {},
"outputs": [
{
"data": {
2021-03-10 20:01:13 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAy4AAAHmCAYAAACVl9pbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAABJ0AAASdAHeZh94AAEAAElEQVR4nOydd3gc1dX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fTdntT8SMlpuVUh8gJgQ/rH/7J4APZdiMM4FfK6UWEhsANgDTiXk+osCvM/5gznwHOF0p9SqxGi5dxOqYnEPMm/S3hG0X9Lfh/5RSB/WvR2v9i/71XyFW6+NnxLKvvUZM9zGVmND8aODS/vOMNv8EPkEsLG55f4iTn5iw/G1gP2KfNRNeAT6vlDqWWEKFeB0XD3B1YuIArfXtSqkjidXK2aCUeoaYjmQCsXowpxAzOL445E84yD397Tif2Gd9jNhn/Rixzzo3cWOtdVQpdSOxOi7L+rcvAOb3t29B/98WtNZaKfVXYoYZJN8/BoPB4ArjcTEYDAYXaK1vIiaIf5PYIPZaYjUtfg0c359CNnH7lcAZxAaqHyYWHhMkZri8M4QmPEPMGCohZqx8k9gg9jngZK31g0M4phM3ESswOJuYMP+rwL79yw9PzC6mtV5FbCZ9F7EB989JSKfbPzA/tf8YTQxev/nEUkl/o/9zjDr9Ga4uINZ+P7E2f4RYcc2v9G8mZShzYhOx0LNWYgbHxcTCtM7VKcUn+9vwZWL3zEJi99C1xIyLSmL32x8yPL9I/2f9OLFEAB5in+98YobRxTa7/YjYvddDLOzrQmLZ344hZmA5cScxo6+X2PU0GAyGjFAmC6HBYDAYDOlRSp0
2021-02-20 00:16:03 +00:00
"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",
2021-03-10 20:01:13 +00:00
" poly = Polynomial.fit(x, year_frame.to_numpy(), 4)\n",
2021-02-20 00:16:03 +00:00
" 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",
2021-03-10 20:01:13 +00:00
"to_display = listening_proportion.resample(\"7D\").mean() # mean requires dropping the last datapoint later\n",
2021-02-20 00:16:03 +00:00
"\n",
"plt.figure(figsize=(8, 4))\n",
2021-03-10 20:01:13 +00:00
"ax = to_display[\"duration_ms\"].plot(lw=3) # plot main time series\n",
2021-02-20 00:16:03 +00:00
"\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": [
2021-02-20 14:12:51 +00:00
"# Imports & Setup"
2021-02-20 00:16:03 +00:00
]
2021-02-01 01:37:22 +00:00
},
{
"cell_type": "code",
2021-03-10 20:01:13 +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-03-10 20:01:13 +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
}