listening-analysis/stats.ipynb
2021-05-07 01:03:08 +01:00

103 lines
9.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Stats\n",
"\n",
"Some easy numbers about habits"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# % of scrobbles with attached URIs"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"95.10% joined tracks\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAS4AAADnCAYAAACg0LuLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWe0lEQVR4nO3deZgU5YHH8e87PRwKcmk03qWgAl4I4hqjHGouyytCIHisd9TENYkxSWXXmDGP7lYOV1dNNrrJboyJiYo5TAoPNFGQ6KNBAREPohTeqCggAjMw8+4fVeg4YWZ6Znr67ar6fZ6nn+luq7t/6Pjjreqq9zXWWkREsqTOdQARka5ScYlI5qi4RCRzVFwikjkqLhHJHBWXiGSOiktEMkfFJSKZo+ISkcxRcYlI5qi4RCRzVFwikjkqLhHJHBWXiGSOiktEMkfFJSKZo+ISkcxRcYlI5qi4RCRzVFwikjkqLhHJHBWXiGSOiktEMkfFJSKZo+ISkcxRcYlI5qi4RCRz6l0HkOrxgmhrYFdgly3chgB9SH4nWt82P7cJWA2sSm8rgRXA6+nP5cCSOPTXVumPIwVmrLWuM0iFeUFkgJHAwcD49OdIYGgvf7QFXgQWt7k9HYd+Yy9/thSIiisHvCDaAZhAUlLjgXHANk5DfVgz8CRwHzAbmBuH/nq3kSTLVFwZ5AVRHfBPwDHp7SDAOA3VNRuAeSQlNht4Ig59/SJK2VRcGeEFUT0wGZgCnAjs4DRQZb0F/AG4KQ79ua7DSO1TcdU4L4j2AS4ATgOGOY5TDc8Dvy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0EEmBTUfXPra2EfgNSWEtdB1G3FNx1aD0IP6FwHkU+/rHVcANwHWadkZaU3HVMC+ItgZOBKYBnwb6OQ1UHeuBWSQjrCgO/fWO80gNUnFlhBdEg0jmAJsGfAro6zZRRTUB9wC3An+IQ3+t4zxS41RcGeQF0WCSkdhUYBIw0GWebnqHZLaG3wO/i0N/ldM0kikqrozzgqgeGE9SYBOBQ4HBLjO141WSopqT/lysZe2lu1RcOeMFkSE5L+xQkjnC9gZGALsApkoxVpAsX/808BgwRwtRSCWpuArCC6J+wJ7A8PQ2In08GBhAsrs5oNWt1OrlFlib3t5Nb5vvvwosS28x8Fwc+u/0+h9ICk3FJVvkBVF/YGugEVin3TqpJSouEckczVAgIpmj4hKRzFFxiUjmqLhEJHNUXCKSOSouEckcFZeIZI6KS0QyR8UlIpmj4hKRzFFxiUjmqLhEJHNUXCKSOSouEckcFZeIZI6KS0QyR8UlIpmj4hKRzFFxiUjmqLhEJHNUXCKSOSouEckcFZeIZI6KS0QyR8UlIpmj4hKRzFFxiUjm/D8gwEWc8U0JMgAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"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": 2,
"metadata": {},
"outputs": [],
"source": [
"from google.cloud import bigquery\n",
"import matplotlib.pyplot as plt\n",
"from dotenv import load_dotenv\n",
"\n",
"load_dotenv()\n",
"\n",
"client = bigquery.Client()"
]
}
],
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}