listening-analysis/stats.ipynb

103 lines
21 KiB
Plaintext
Raw Normal View History

{
"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.8.4 64-bit ('listening-analysis-_rwRS6J3-py3.8': venv)",
"metadata": {
"interpreter": {
"hash": "e85d407c5e6377acc22c75bda570bea5002f956bfcfcd37c4bd67d7795879c64"
}
}
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"source": [
"# Stats\n",
"\n",
"Some easy numbers about habits"
],
"cell_type": "markdown",
"metadata": {}
},
{
"source": [
"# % of scrobbles with attached URIs"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"94.67%\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n<!-- Created with matplotlib (https://matplotlib.org/) -->\r\n<svg height=\"231.84pt\" version=\"1.1\" viewBox=\"0 0 302.436865 231.84\" width=\"302.436865pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <metadata>\r\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#\">\r\n <cc:Work>\r\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\r\n <dc:date>2021-01-31T21:11:06.218715</dc:date>\r\n <dc:format>image/svg+xml</dc:format>\r\n <dc:creator>\r\n <cc:Agent>\r\n <dc:title>Matplotlib v3.3.4, https://matplotlib.org/</dc:title>\r\n </cc:Agent>\r\n </dc:creator>\r\n </cc:Work>\r\n </rdf:RDF>\r\n </metadata>\r\n <defs>\r\n <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\r\n </defs>\r\n <g id=\"figure_1\">\r\n <g id=\"patch_1\">\r\n <path d=\"M 0 231.84 \r\nL 302.436865 231.84 \r\nL 302.436865 0 \r\nL 0 0 \r\nz\r\n\" style=\"fill:none;\"/>\r\n </g>\r\n <g id=\"axes_1\">\r\n <g id=\"patch_2\">\r\n <path d=\"M 222.508494 115.92 \r\nC 222.508494 105.110361 220.493313 94.394848 216.566431 84.323707 \r\nC 212.639548 74.252566 206.869352 65.001186 199.552144 57.044631 \r\nC 192.234936 49.088077 183.498147 42.564911 173.790414 37.810102 \r\nC 164.082681 33.055293 153.573065 30.151645 142.801241 29.248264 \r\nC 132.029418 28.344882 121.182977 29.457498 110.81889 32.528979 \r\nC 100.454804 35.60046 90.753561 40.577316 82.213328 47.203982 \r\nC 73.673095 53.830648 66.442599 61.991722 60.89313 71.268126 \r\nC 55.343661 80.544531 51.571863 90.774718 49.77142 101.433362 \r\nC 47.970977 112.092006 48.173244 122.993487 50.367834 133.578006 \r\nC 52.562424 144.162526 56.711119 154.245756 62.60088 163.309916 \r\nC 68.490641 172.374077 76.018899 180.261315 84.799073 186.566617 \r\nC 93.579246 192.871919 103.45843 197.485478 113.929321 200.170386 \r\nC 124.400212 202.855293 135.28046 203.564791 146.011359 202.262446 \r\nC 156.742257 200.960101 167.136928 197.668594 176.661598 192.556946 \r\nC 186.186268 187.445297 194.675065 180.602526 201.692085 172.380014 \r\nC 208.709105 164.157501 214.132147 154.698441 217.682734 144.488563 \r\nL 135.532494 115.92 \r\nL 222.508494 115.92 \r\nz\r\n\" style=\"fill:#1f77b4;\"/>\r\n </g>\r\n <g id=\"patch_3\">\r\n <path d=\"M 217.682734 144.488563 \r\nC 219.277208 139.903578 220.485039 135.193144 221.29357 130.406631 \r\nC 222.102101 125.620118 222.508495 120.774307 222.508494 115.919986 \r\nL 135.532494 115.92 \r\nL 217.682734 144.488563 \r\nz\r\n\" style=\"fill:#ff7f0e;\"/>\r\n </g>\r\n <g id=\"matplotlib.axis_1\"/>\r\n <g id=\"matplotlib.axis_2\"/>\r\n <g id=\"text_1\">\r\n <!-- No URI -->\r\n <g transform=\"translate(7.2 102.744073)scale(0.1 -0.1)\">\r\n <defs>\r\n <path d=\"M 9.8125 72.90625 \r\nL 23.09375 72.90625 \r\nL 55.421875 11.921875 \r\nL 55.421875 72.90625 \r\nL 64.984375 72.90625 \r\nL 64.984375 0 \r\nL 51.703125 0 \r\nL 19.390625 60.984375 \r\nL 19.390625 0 \r\nL 9.8125 0 \r\nz\r\n\" id=\"DejaVuSans-78\"/>\r\n <path d=\"M 30.609375 48.390625 \r\nQ 23.390625 48.390625 19.1875 42.75 \r\nQ 14.984375 37.109375 14.984375 27.296875 \r\nQ 14.984375 17.484375 19.15625 11.84375 \r\nQ 23.34375 6.203125 30.609375 6.203125 \r\nQ 37.796875 6.203125 41.984375 11.859375 \r\nQ 46.1875 17.53125 46.1875 27.296875 \r\nQ 46.1875 37.015625 41.984375 42.703125 \r\nQ 37.796875 48.390625 30.609375 48.390625 \r\nz\r\nM 30.609375 56 \r\nQ 42.328125 56 49.015625 48.375 \r\nQ 55.71875 40.765625 55.71875 27.296875 \r\nQ 55.71875 13.875 49.015625 6.21875 \r\nQ 42.328125 -1.421875 30.609375 -1.421875 \r\nQ 18.84375 -1.421875 12.171875 6.21875 \r\nQ 5.515625 13.875 5.515625 27.296875 \r\nQ 5.515625 40.765625 12.171875 48.375 \r\nQ 18.84375 56 30.609375 56 \r\nz
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAS4AAADnCAYAAACg0LuLAAAAOXRFWHRTb2Z0d2FyZQBNY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9u/bdq4lXjj3b7zlMlrjF0Ez/mOUVhlKK4e3wHK6kXGrXlmz6FrntlzKNvaY38/qf2653cZ9dAm7bZoXd/Zim5lFgy0wabUoAzFpRFXE/zVbbLZ4QujzcC53UbNnvPF9hvmbWuPbzHKnM5cGJ7ewZ8iA1FxyRCZTVvUMX5adwdt9PZMHnXPzOPbf/fmZvbUeDN9xD8E+rkdARWXDFsvbe03Ltp5+xu7d2YM3W8e0HbHjKPbEjawFzrMWN53vhb3su8ARVaG4ur2HUCgi9HLX9U7acereiexIgteObxt6szD2qcuvxbzOsxK8XNWb//xHaDIzLlizxEGUXIK8H3fOWTpVmP+S8e23/TwAW3Txo3j9a3NtO4O6KZz/hjfIYqsDOu4nvYdQAY2l1VW/07PIRMndP1k/K7d5z73i54P3/G6G/M337k802hrhMpQXM/4DiC1ecatue7Xeo750JZdl2++R9d3n7yp9wPTulz7k75zeaDiGqEyzD1oxFVAj7n1N/riwpM2Aqq4RkzFNUJlKK5/ka2J0UU2C6qCa8Re8B2g6Ao/OQ8QRMkzwHq+c0j95GvEZpV0jdjZdM7/uu8QRVaGOS7Q4WLpLF4jtmd3/MHNuq4Y/Y2FR85IF619t3O86TtbHTxa6xPN7JNm5sxssz6PdZjZ5D5f72ZmOw83jJm9NtzX5q9Pzewdo+P+72tmR5jZefn9TjN71sxmmdkjZnZwn+ddYWZTlvU9VVzS8roYvfzPeiftuFv3OTtt1XXpwu8tPPCu592qM50
},
"metadata": {}
}
],
"source": [
"no_uri = (\n",
" 'SELECT ' \n",
" ' COUNT(track) '\n",
" 'FROM `sarsooxyz.scrobbles.*` '\n",
" 'WHERE '\n",
" ' uri IS NOT NULL '\n",
")\n",
"\n",
"uri = (\n",
" 'SELECT ' \n",
" ' COUNT(track) '\n",
" 'FROM `sarsooxyz.scrobbles.*` '\n",
")\n",
"\n",
"no_uri_count = list(client.query(no_uri).result())[0][0]\n",
"uri_count = list(client.query(uri).result())[0][0]\n",
"\n",
"print(f'{( no_uri_count / uri_count ) * 100:.2f}% joined tracks')\n",
"plt.pie([no_uri_count, uri_count - no_uri_count], labels=[\"No URI\", \"Attached URI\"])\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"from google.cloud import bigquery\n",
"import matplotlib.pyplot as plt\n",
"\n",
"client = bigquery.Client()"
]
}
]
}