listening-analysis/track.ipynb

257 lines
334 KiB
Plaintext
Raw Normal View History

2021-05-10 00:18:57 +01:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Track Investigations"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"58 scrobbles\n4 hours spent listening since Nov. 2017\n"
]
}
],
"source": [
"track_name = \"never\".lower()\n",
"artist_name = \"jid\".lower()\n",
"\n",
"track_frame = scrobbles[scrobbles[\"track\"].str.lower() == track_name]\n",
"track_frame = track_frame[track_frame[\"artist\"].str.lower() == artist_name]# FILTER SCROBBLES\n",
"track_frame = track_frame.sort_index(ascending=False) # SORT\n",
"# track_frame = track_frame.loc[:, descriptor_headers] # DESCRIPTORS\n",
"\n",
"total_time = track_frame[\"duration_ms\"].sum() / (1000 * 60 * 60) # hours\n",
"\n",
"print(f'{track_frame.count()[0]:,d} scrobbles')\n",
"print(f'{total_time:.0f} hours spent listening since Nov. 2017')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 720x480 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg height=\"288.512187pt\" version=\"1.1\" viewBox=\"0 0 362.5625 288.512187\" width=\"362.5625pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-10T00:18:14.489184</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.4.1, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 288.512187 \nL 362.5625 288.512187 \nL 362.5625 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 20.5625 239.758125 \nL 355.3625 239.758125 \nL 355.3625 22.318125 \nL 20.5625 22.318125 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <path clip-path=\"url(#p1f3cae870c)\" d=\"M 118.2125 239.758125 \nL 118.2125 22.318125 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_2\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"ma211d3c63b\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"118.2125\" xlink:href=\"#ma211d3c63b\" y=\"239.758125\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- Jan -->\n <g transform=\"translate(110.504688 254.356562)scale(0.1 -0.1)\">\n <defs>\n <path d=\"M 628 4666 \nL 1259 4666 \nL 1259 325 \nQ 1259 -519 939 -900 \nQ 619 -1281 -91 -1281 \nL -331 -1281 \nL -331 -750 \nL -134 -750 \nQ 284 -750 456 -515 \nQ 628 -281 628 325 \nL 628 4666 \nz\n\" id=\"DejaVuSans-4a\" transform=\"scale(0.015625)\"/>\n <path d=\"M 2194 1759 \nQ 1497 1759 1228 1600 \nQ 959 1441 959 1056 \nQ 959 750 1161 570 \nQ 1363 391 1709 391 \nQ 2188 391 2477 730 \nQ 2766 1069 2766 1631 \nL 2766 1759 \nL 2194 1759 \nz\nM 3341 1997 \nL 3341 0 \nL 2766 0 \nL 2766 531 \nQ 2569 213 2275 61 \nQ 1981 -91 1556 -91 \nQ 1019 -91 701 211 \nQ 384 513 384 1019 \nQ 384 1609 779 1909 \nQ 1175 2209 1959 2209 \nL 2766 2209 \nL 2766 2266 \nQ 2766 2663 2505 2880 \nQ 2244 3097 1772 3097 \nQ 1472 3097 1187 3025 \nQ 903 2953 641 2809 \nL 641 3341 \nQ 956 3463 1253 3523 \nQ 1550 3584 1831 3584 \nQ 2591 3584 2966 3190 \nQ 3341 2797 3341 1997 \nz\n\" id=\"DejaVuSans-61\" transform=\"scale(0.015625)\"/>\n <path d=\"M 3513 2113 \nL 3513 0 \nL 2938 0 \nL 2938 2094 \nQ 2938 2591 2744 2837 \nQ 2550 3084 2163 3084 \nQ 1697 3084 1428 2787 \nQ 1159 2491 1159 1978 \nL 1159 0 \nL 581 0 \nL 581 3500 \nL 1159 3500 \nL 1159 2956 \nQ 1366 3272 1645 3428 \nQ 1925 3584 2291 3584 \nQ 2894 3584 3203 3211 \nQ 3513 2838 3513 2113 \nz\n\" id=\"DejaVuSans-6e\" transform=\"scale(0.015625)\"/>\n </defs>\n <use xlink:href=\"#DejaVuSans-4a\"/>\n <use x=\"29.492188\" xlink:href=\"#DejaVuSans-61\"/>\n <use x=\"90.771484\" xlink:href=\"#DejaVuSans-6e\"/>\n </g>\n <!-- 2019 -->\n <g transform=\"translate(105.4875 265.554375)scale(0.1 -0.1)\">\n <defs>\n <path d=\"M 1228 531 \nL 3431 531 \nL 3431 0 \nL 469 0 \nL 469 531 \nQ 828 903 1448 1529 \nQ 2069 2156 2228 2338 \nQ 2531 2678 2651 2914 \nQ 2772 3150 2772 3378 \nQ 2772 3750 2511 3984 \nQ 2250 4219 1831 4219 \nQ 1534 4219 1204 4116 \nQ 875 4013 500 3803 \nL 500 4441 \nQ 881 4594 1212 4672 \nQ 1544 4750 1819 4750 \nQ 2544 4750 2975 4387 \nQ 3406 4025 3406 3419 \nQ 3406 3131 3298 2873 \n
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlwAAAHmCAYAAACmpVA+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAABJ0AAASdAHeZh94AAB1M0lEQVR4nO3dd3hc13Xv/e9CbwRAgL13i+oVpJotyjXuPbHl7tiW5RrfOPem2r7JTZ7XSZxYcq9yjy1bttybRHWRsHqjxAp2Eizovez3j3POYDBEG2DKOQe/z/PgITXlzMbR8Myatdde25xziIiIiEj2FOR7ACIiIiJxp4BLREREJMsUcImIiIhkmQIuERERkSxTwCUiIiKSZQq4RERERLJMAZeIiIhIlingEhEREckyBVwiIiIiWaaAS0RERCTLFHCJiIiIZJkCLhHJOzN7h5k5M3tHyu1NZtaUxnFW+ce5OcNDDIXxztMkz7nZf86qNJ6T1nkXkckp4BKRWc3Myszsr81su5m1mVm/mR01s4fM7HNm9rx8j1FEoq8o3wMQEQF+CmwDjqbc/vxsvqiZVQF3ARcDx4Cf+H9WARcA7wVq/ceIiEybAi4RyTvnXBvQNsbte7L80h/FC7Z+D7zCOdeffKeZzQU2ZnkMIjILaEpRJIOSa4j8v/+PmZ00s14ze9DMXj7Bc99kZlvNrNV//A4z+wczK016zFIzGzKzRyY4zm/8MZybcvsmM/uxmR3zp80OmtmXzWzJGMe40z9GiZn9k5k9a2Z92aqNSreGy8zmmNlnzOyQf66eMbOPkf417Qr/zy+mBlsAzrkW59z9Y7x+oZldb2b3+dOQPWa228y+Zmbrkx73Sf/3usbM3uxPW3Ym/05mttjMPu//rv1mdsLMbjWzSyYauJm9zMzuN7MuM2vx/9+un+ApBWb2Mf9c9frn7r/MrHrSszT6dSd9nyY99moz+4X/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PedTwCbgFcBOM/slXiZsOfAivFq5m6f4+tf7r/vvZvYi4EFG+nANA+/0s3qpfgH81Mx+ipfxuxAvY3Qa7300lvuAR/0C9jb/97sAb6HEpycb6DTepzfiZSLvw6vj6wcuwZue3Q/8z2SvKRInCrhEQsA59wEz+w3eh9UL8AKI03gfaP8OfHecp96MF3AVcWaxfPLxv2tmj+EVMG/BCwy6gCPAj4EfZuL3yAXnXJ+ZvQCv5cKf4/WfagL+BS8blE7A9TfAPXjnfDNe49IivALzXwLfcCmNR51z/X5Tz+vxMotvx5tyPOK//r1p/C57zexS4B+Al+JNibYDvwX+X0qgl+xWvEa2f483nTzg3/a3zrmd4zznr/zf7z14WbVTeIsC/slNoempP9503qf/6r/epf5jh/3H/Svw3865lqm8pkhcWJo1sSIiGWdm1wNfBN7snPvBZI8XEYka1XCJSBgEtWXq0SQisaQMl4jkjZm9Am8q7R14U1yrx2kCKiISacpwiUg+vQ6vDutu4AUKtkQkrpThEhEREckyZbhEREREskwBl4iIiEiWKeASERERybJQND41sxq8fb4O4nUjFhEREQmrErxdIe5yzk208XtCKAIuvGDrtnwPQkRERCQNrwJ+PpUHhiXgOgjws5/9jHXr1uV7LDKLdXZ20tjYSENDA1VVVfkejojEhK4t8bJ7925e/epXgx+/TEVYAq5+gHXr1nHOOefkeywyi7W3t3Ps2DE2btxIdXV1vocjIjGha0tsTbkMSkXzIiIiIlmmgEtEREQkyxRwiYiIiGSZAi4RERGRLFPAJSIiIpJlCrhEREREskwBl4iIiEiWKeASERERybJpB1xmdrOZuQl+lmZyoCIiIiJRNZNO818G/phymwFfApqcc4dncGwRERGR2Jh2wOWcewB4IPk2M7sKqAC+N8NxiYiIiMRGpmu
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"# resample by day and mean\n",
"track_frame.resample(\"1M\").count()[\"track\"].plot()\n",
"\n",
"plt.title(f\"{track_name} - {artist_name} Scrobbles\")\n",
"plt.grid()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Average Descriptor\n",
"\n",
"Below presents the average descriptor for the album. \"*All Listened Tracks*\" describes the descriptor based on the listening activity for this album. This takes into account how many times a track is listened to. \"*Distinct Tracks*\" takes only the distinct set of tracks that have been listened to and takes that average.\n",
"\n",
"The difference between them could be described as which features are preferred for an album. If the blue bar is higher than the red, it would indicate that tracks from this album which have a higher value for this are listened to more. "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 720x480 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg height=\"263.63625pt\" version=\"1.1\" viewBox=\"0 0 372.103125 263.63625\" width=\"372.103125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-10T00:18:17.279113</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.4.1, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 263.63625 \nL 372.103125 263.63625 \nL 372.103125 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 30.103125 239.758125 \nL 364.903125 239.758125 \nL 364.903125 22.318125 \nL 30.103125 22.318125 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"patch_3\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 45.321307 239.758125 \nL 81.128793 239.758125 \nL 81.128793 233.517597 \nL 45.321307 233.517597 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_4\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 90.080665 239.758125 \nL 125.888152 239.758125 \nL 125.888152 110.598765 \nL 90.080665 110.598765 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_5\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 134.840023 239.758125 \nL 170.64751 239.758125 \nL 170.64751 99.509325 \nL 134.840023 99.509325 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_6\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 179.599382 239.758125 \nL 215.406868 239.758125 \nL 215.406868 239.754515 \nL 179.599382 239.754515 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_7\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 224.35874 239.758125 \nL 260.166227 239.758125 \nL 260.166227 225.233133 \nL 224.35874 225.233133 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_8\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 269.118098 239.758125 \nL 304.925585 239.758125 \nL 304.925585 171.264525 \nL 269.118098 171.264525 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_9\">\n <path clip-path=\"url(#p2955770898)\" d=\"M 313.877457 239.758125 \nL 349.684943 239.758125 \nL 349.684943 195.182925 \nL 313.877457 195.182925 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"mc0290095fd\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"63.22505\" xlink:href=\"#mc0290095fd\" y=\"239.758125\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- acoust -->\n <g transform=\"translate(46.6188 254.356563)scale(0.1 -0.1)\">\n <defs>\n <path d=\"M 2194 1759 \nQ 1497 1759 1228 1600 \nQ 959 1441 959 1056 \nQ 959 750 1161 570 \nQ 1363 391 1709 391 \nQ 2188 391 2477 730 \nQ 2766 1069 2766 1631 \nL 2766 1759 \nL 2194 1759 \nz\nM 3341 1997 \nL 3341 0 \nL 2766 0 \nL 2766 531 \nQ 2569 213 2275 61 \nQ 1981 -91 1556 -91 \nQ 1019 -91 701 211 \nQ 384 513 384 1019 \nQ 384 1609 779 1909 \nQ 1175 2209 1959 2209 \nL 2766 2209 \nL 2766 2266 \nQ 2766 2663 2505 2880 \nQ 2244 3097 1772 3097 \nQ 1472 3097 1187 3025 \nQ 903 2953 641 2809 \nL 641 3341 \nQ 956 3463 1253 3523 \nQ 1550 3584 1831 3584 \nQ 2591 3584 2966 3190 \nQ 3341 2797 3341 1997 \nz\n\" id=\"DejaVuSans-61\" transform=\"scale(0.015625)\"/>\n <path d=\"M 3122 3366 \nL 3122 2828 \nQ 2878
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAG5CAYAAAAzjmgkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAABJ0AAASdAHeZh94AAA3LElEQVR4nO3debgdRZn48e/LFtAQdgSiGEGRiApuIIoSUXRGEBdAcEHABZRRFhXElTj8HBRxXIcRZsCIwsjiggoCigRcE0UQQRYJRlASA0KM0RC2+v1RdaTpnHvvuecm9xTJ9/M8/Zx7q6u6q+t093lPdXWfSCkhSZKke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dkR8OCKW+RCOiK0j4gmjqPPc8jqttZytgE+0M6eU7iVfNl0P+FCrzPY89F40y/yS/CiP15RHrCwjIp5WLgWPSXmu2eeAA8i9Xsc26jGq9ivPJ3t+lzxrkm/IgHwDBsB3yG25V3R/nttjx7JdLasDnyjBfWf5TwAOJwf6X23k/Ut53XKIZZ1OvoT/yWZ7RMTGwIcbeaRHDMewSStASun0csPAYcCciLiY/HM8G5IfVfBC8rOm3t4qd1tEXEZ+NMf9wG9SSlfRklK6oQQJpwPXRcRF5GdHrUn+EHsBeYzTtmPZjvKB+RLyZdlvDZP1bOAzwN4R8a6U0l0l/cvkwfonNP7v5p3kZ8j9O3BARPyYPKZpC/Jg+eeQLw93G5TezXfIjzx5d0Q8jdw7syX5rtYL6P5BfyywG3BMROxEfibY5uRngV0IvIocTDe9ntwrdVpEHE5+htdC8mXLp5N7qnamx2fdFUdGxEJywNH5aaoXkp/vdhP
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"plt.bar(np.arange(len(float_headers)), track_frame[float_headers].mean())\n",
"\n",
"plt.title(f\"{track_name} Average Descriptor\")\n",
"plt.xticks(np.arange(len(float_headers)), labels=[i[:6] for i in float_headers])\n",
"plt.ylim([0, 1])\n",
"plt.grid(axis='y')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Track Listening Time"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"LIMIT = 25\n",
"fig_size = (7,(10/20)*LIMIT)\n",
"### STATS ###\n",
"\n",
"stats_frame = scrobbles.reset_index()[[\"track\", \"album\", \"artist\", \"duration_ms\"]]\n",
"\n",
"track_count = stats_frame.groupby(['artist', 'track']).count()[\"album\"]\n",
"track_count.name='count'\n",
"\n",
"duration_sum = stats_frame.groupby(['artist', 'track']).sum()[\"duration_ms\"]\n",
"duration_sum.name=\"duration_sum\"\n",
"\n",
"duration_average = stats_frame.groupby(['artist', 'track']).mean()[\"duration_ms\"]\n",
"duration_average.name=\"duration_mean\"\n",
"\n",
"stats_frame = pd.concat([track_count, duration_sum, duration_average], axis=1).reset_index()\n",
"\n",
"stats_frame = stats_frame[stats_frame[\"track\"] != \"Mirror Reaper\"] # 1:30 hr long song, skews graphs\n",
"# stats_frame"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 840x1500 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg height=\"739.374375pt\" version=\"1.1\" viewBox=\"0 0 714.225 739.374375\" width=\"714.225pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <metadata>\n <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2021-05-10T00:18:19.067566</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.4.1, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 739.374375 \nL 714.225 739.374375 \nL 714.225 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 316.425 701.818125 \nL 707.025 701.818125 \nL 707.025 22.318125 \nL 316.425 22.318125 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"patch_3\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 73.131175 \nL 688.425 73.131175 \nL 688.425 53.204489 \nL 316.425 53.204489 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_4\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 98.039533 \nL 680.995142 98.039533 \nL 680.995142 78.112846 \nL 316.425 78.112846 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_5\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 122.94789 \nL 644.917305 122.94789 \nL 644.917305 103.021204 \nL 316.425 103.021204 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_6\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 147.856248 \nL 629.180069 147.856248 \nL 629.180069 127.929562 \nL 316.425 127.929562 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_7\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 172.764606 \nL 617.528655 172.764606 \nL 617.528655 152.83792 \nL 316.425 152.83792 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_8\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 197.672964 \nL 605.765369 197.672964 \nL 605.765369 177.746277 \nL 316.425 177.746277 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_9\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 222.581321 \nL 600.660074 222.581321 \nL 600.660074 202.654635 \nL 316.425 202.654635 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_10\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 247.489679 \nL 600.607161 247.489679 \nL 600.607161 227.562993 \nL 316.425 227.562993 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_11\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 272.398037 \nL 599.553941 272.398037 \nL 599.553941 252.471351 \nL 316.425 252.471351 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_12\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 297.306395 \nL 598.234897 297.306395 \nL 598.234897 277.379709 \nL 316.425 277.379709 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_13\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 322.214753 \nL 589.899094 322.214753 \nL 589.899094 302.288066 \nL 316.425 302.288066 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_14\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 347.12311 \nL 586.994961 347.12311 \nL 586.994961 327.196424 \nL 316.425 327.196424 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_15\">\n <path clip-path=\"url(#p502d881124)\" d=\"M 316.425 372.031468 \nL 583.294237 372.031468 \nL 583.294237 352.104782 \nL 316.425 352.104782 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_16\">\n
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKQAAATTCAYAAABLBO+pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAABJ0AAASdAHeZh94AAEAAElEQVR4nOzdedxt5fz/8ddbSSWnhGQOZSxCZFZ+5nmeSjKFzEQyhsx8haQUmiSpZC7hNBkiFJ2I4kTRPJzSXJ/fH9fatc8++x7PffY+dV7Px2M/9r3XutZan3Wtdd+1P+e6PitVhSRJkiRJkjQqNxt3AJIkSZIkSVqxmJCSJEmSJEnSSJmQkiRJkiRJ0kiZkJIkSZIkSdJImZCSJEmSJEnSSJmQkiRJkiRJ0kiZkJIkSZIkSdJImZCSJEmSJEnSSJmQkiRJkiR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6QZN4MtwO4pHsfOtdwKf2me3/qDNouy2u1L/BH2lMoNxlcWVWXAKcBd0qywZDte4nLP/Qv7OppHUh78uATaDXJVma0o6NWpY0kvJZWSH8q9+neT1hWMUnLOxNSkiRJ0vKhN1JmjyR3HFyZ5JZJHj64fFlI8sgkqw1Z1RtRdFnfst70wSWKM3eFqL8JbJLkAwNF3HvHumeSuw8un66uPtCXaKNnvjgs7iR3SHK/vkV7de/vS7J2X7tVgU/MIowjad+tHja4IslLkzyxK74+uG5d4LXdx6NncdypfIU2le8DA+ffO/6d+z7uQqth9vkk9xrSdpVuGuesdTWytqMl3ybq56936z/Tf78kuS3wgb42g/bq3rfqXtfQ7r1ReSFtNOFPpihm3tP
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"duration_frame = stats_frame.sort_values(by='duration_sum', ascending=False).head(LIMIT)\n",
"\n",
"plt.figure(figsize=fig_size)\n",
"plt.barh(np.arange(len(duration_frame))[::-1], duration_frame[\"duration_sum\"].to_numpy() / (1000 * 60 * 60) )\n",
"plt.yticks(np.arange(len(duration_frame))[::-1], labels=[f'{r[\"track\"]} - {r[\"artist\"]}' for i, r in duration_frame.iterrows()])\n",
"plt.xlabel(\"Time (Hours)\")\n",
"plt.grid(axis=\"x\")\n",
"plt.title(\"Time Listened (Since Nov 17)\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Imports & Setup"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"from google.cloud import bigquery\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"mpl.rcParams['figure.dpi'] = 120\n",
"\n",
"from analysis.net import get_spotnet, get_fmnet, get_playlist\n",
"from analysis.query import *\n",
"from analysis import float_headers, days_since\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"client = bigquery.Client()\n",
"spotnet = get_spotnet()\n",
"fmnet = get_fmnet()\n",
"cache = 'query.csv'\n",
"first_day = datetime(year=2017, month=11, day=3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read Scrobble Frame"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"scrobbles = get_query(cache=cache)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Write Scrobble Frame"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"scrobbles.reset_index().to_csv(cache, sep='\\t')"
]
}
],
"metadata": {
"kernelspec": {
"name": "pythonjvsc74a57bd0bce1a3677099e73bf385a0de8ef462673e03f7df0abce93e57e7ca76e8c504a2",
"display_name": "Python 3.8.9 ('.venv': poetry)"
},
"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.9"
},
"metadata": {
"interpreter": {
"hash": "bce1a3677099e73bf385a0de8ef462673e03f7df0abce93e57e7ca76e8c504a2"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}