2024-05-02 03:05:34 +00:00
{
"cells": [
{
"cell_type": "code",
2024-05-06 06:04:45 +00:00
"execution_count": 1,
2024-05-02 03:05:34 +00:00
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from datetime import datetime, timezone, timedelta\n",
"import pytz\n",
2024-05-04 10:52:52 +00:00
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"import sqlite3\n",
"\n",
2024-05-06 06:04:45 +00:00
"plt.rcParams[\"font.family\"] = \"Helvetica Neue\"\n",
"\n",
2024-05-04 10:52:52 +00:00
"db = sqlite3.connect(\"./scores.db\")\n",
2024-05-02 03:05:34 +00:00
"\n",
"with open(\"data/output.csv\", \"rb\") as f:\n",
" data = pd.read_csv(f, delimiter=\"\\t\")"
]
},
{
"cell_type": "code",
2024-05-06 06:04:45 +00:00
"execution_count": 11,
2024-05-04 10:52:52 +00:00
"metadata": {},
"outputs": [
{
2024-05-06 06:04:45 +00:00
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x13f6d8550>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
2024-05-04 10:52:52 +00:00
},
{
"data": {
2024-05-06 06:04:45 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA8sAAAHQCAYAAACWf/jeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOzdd3wUdf7H8Xd6JQkECCAQeu9NeudoCojAKaAEKypyop56CgcKd4oVy/ETFQWkSRWVKr1K9aQI0hFFEEgIBEIgyfz+CNkjS4DsZpOZHV7PxyMP2NnZyec935nNfnZmdn0MwzAEAAAAAAAcfM0uAAAAAAAAq6FZBgAAAADACc0yAAAAAABOaJYBAAAAAHBCswwAAAAAgBOaZQAAAAAAnNAsAwAAAADghGYZAAAA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GDh0qKeMU20zu1H+tW60fd7iyfvJj/efleLm7fdaoUUPdunVz3A4KClLnzp2Vmpqaq1PgXa2nfPnyatSokZYuXaqEhATH9KSkJC1cuFA1a9ZUzZo1HdOtuL3ltdjY2CyXskRHR6tgwYKO+y5fvuy4dCS36wcA3MVp2AC8yvLly1WxYkWVKlVKkrRixQrVrFlThQsXztVyf/75Z0lSvXr1rruvbt26WebJL71799Z///tftWzZUn379lWzZs3UqFEjxcTEXDfv+fPntXfvXhUpUkS1atW65bJzm9f5hbmzzZs3S5L27dunkSNHZrkvs8nat29flumu5HVXzZo15efnl2Va7dq1JSnLNZLu1H+tW60fd7iyfvJj/efleLm7fVauXPm6aUWKFJGkXF237E49ffv21ebNmzV37lw9/PDDkjJOT05OTs7yho1kze0tr2W+8SllvOFy7Rt8mW/AZH6WQG7XDwC4i2YZgOWNHTtWZ8+elSStWbNGsbGxjhdMGzduVJUqVRy3nV9I5VTmB/FER0dfd19mI+6pDwnKqX/84x8qUqSIJkyYoLfffltjxoyRj4+Pmjdvrs8++0yVKlVyzJuYmChJOf5E7tzmzXyz4kYyx+tm14leuHAhy21X8roruyNtmevg2rzu1H+tW60fd7iyfvJj/efleLm7fYaHh183LfM6ViMX35TpTj333XefnnvuOc2YMcPRLM+YMUM+Pj66//77s8xrxe0tr117fbGvr+91tyUpLS1NUu7XDwC4i9OwAVje2LFj9eqrr+rVV19VUlKSdu/e7bidkpKin376yXHbXZkvss+cOXPdfadPn5YkFShQwO3lu8PHx0ePPvqofvjhB509e1aLFy9W165dtXbtWt17771Z5o2MjJQkHT9+PEfLzm3eW313amY9GzZskGEY2f4cPnw4y2Ncyeuu7D4RPHMdXNtouVP/tfLiu2Xd2R7ycv3n5XhZbX90p56YmBi1bdtWK1eu1J9//qmEhAQtXbpUzZo1c3yCfiYrbm9Wktv1AwDuolkGYHlHjhyRYRj617/+JUk6ceKEDMPQ8OHD5efnp8TERMcLJndlXs/7448/Xndf5rRrr/nNb+Hh4erYsaO++eYbVa5cWbt27XK8SJcyXqhXqVJFp06d0s6dO2+5vLzO27BhQ0nSpk2b3Hr8rfK6a+fOnY6jVZl27NghSVmuhcxt/XntVusnv9e/p8fLavuju/X07dtXaWlpmjVrlubMmaMrV65c9+nYkrW3t8zLFnLzlXy5ZeX1A8DeaJYBeI0VK1aoevXqjmsiV6xYofr16ysiIiLXy+7WrZsCAwM1efJkHTp0yDH91KlT+s9//iNJ6tWrV65/jysWL1583QvU+Ph4nTp1SoGBgQoLC8ty36BBgyRJQ4YMue57g//44w/t3bvXcTuv8z744IM
2024-05-04 10:52:52 +00:00
"text/plain": [
2024-05-06 06:04:45 +00:00
"<Figure size 1200x500 with 1 Axes>"
2024-05-04 10:52:52 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from datetime import date, datetime\n",
2024-05-06 06:04:45 +00:00
"import july\n",
"from july.utils import date_range\n",
"from utils import CST\n",
2024-05-04 10:52:52 +00:00
"c = db.cursor()\n",
"result = c.execute(\"\"\"\n",
" SELECT COUNT(*), UNIXEPOCH(DATE(scores.\"Time Played\")) as date FROM scores\n",
" GROUP BY date\n",
"\"\"\")\n",
"result = list(result)\n",
"result.sort(key=lambda x: x[1])\n",
"y, x = list(zip(*result))\n",
2024-05-06 06:04:45 +00:00
"dates = list(map(lambda x: datetime.utcfromtimestamp(x).astimezone(tz=None), x))\n",
2024-05-04 10:52:52 +00:00
"# dates = matplotlib.dates.date2num(x)\n",
2024-05-06 06:04:45 +00:00
"# plt.title(\"Amount of maps played per session over time\")\n",
"# plt.xticks(rotation=45, ha=\"right\")\n",
"# plt.plot(dates, y)\n",
"# plt.gcf().autofmt_xdate()\n",
"# plt.show()\n",
"july.heatmap(dates, y, title='# of scores per session over time',\n",
" # cmap='Pastel1',\n",
" # date_label=True,\n",
" value_label=True,\n",
" month_grid=True,\n",
")"
2024-05-04 10:52:52 +00:00
]
},
{
"cell_type": "code",
2024-05-06 06:04:45 +00:00
"execution_count": 3,
2024-05-04 10:52:52 +00:00
"metadata": {},
"outputs": [
{
"data": {
2024-05-06 06:04:45 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiUAAAIUCAYAAADFS1zjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOydd3gd1Zn/PzO3VzVLsmXLKi5yAwymhIDpNZsCARIwyZJAIAFnf1kCbPpCym422WyS3QRSNiSQhARCQsmSUEIxAdMxYNzBkrvVy+1lZs7vj7lVupKvZJUr63yeZ56Ze865Z84cjWa+9z3veY8ihBBIJBKJRCKRTDHqVDdAIpFIJBKJBKQokUgkEolEUiJIUSKRSCQSiaQkkKJEIpFIJBJJSSBFiUQikUgkkpJAihKJRCKRSCQlgRQlEolEIpFISgIpSiQSiUQikZQEUpRIJBKJRCIpCaQokUgkJc2BAwdYs2YNdXV1KIqCoijcddddU92sacOuXbtQFIVPfOITE1L/XXfdlfm7pLd169ZNyLkmgune/iMN61Q3QDK13H///XzkIx8B4Fe/+tWEPbgkkrHyiU98gieffJIrrriChQsXoigKK1eunOpmSVKsXLmSW2+9FYB169bx7LPPTnGLRsd0b/+RhhQlM5wHHniA2bNnY7fbefDBB6UokZQU8Xicp556inPOOYd77rlnqpsjKcDKlSszIvG2226bdi/16d7+Iw0pSmYwiUSCv/71r3z4wx/G4XBw9913Ew6H8Xg8U900iQSAjo4ODMOgrq5uqpsikUgmAelTMoN58sknCQQCXHDBBVxwwQXEYjEeffTRIeWWLl2K2+0mFAoNyYtGo/h8PhoaGhi84PTrr7/OpZdeSk1NDQ6Hg0WLFnHbbbcRj8cLtue2227LjOc+9thjrF69Gp/PR1lZGaeccgrvvPNOpuxdd93FpZdeyoIFC3C5XJSVlfHe976XO++8c0g7AIQQ/Nd//ReLFi3KtOWOO+7IO+dgRtv+0fKnP/2J008/ndra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XWnXz6Fri3dB+k+KcSh+n8y+mc0TPT1jpbR9s9o7+fR3g+lxljun8l8/kimFjkleAaSHrp54IEHEKZfUWZ7+OGH88rksmbNGnRd5/777+dPf/oTyWSSK6+8cki5E044ATCnH04E7777LmD+ehpM2nSby1FHHQXAhg0bhuS98cYbQ9Imuv2D8Xq9nH/++fz5z3+mpaWFTZs25Qkon8/HkiVL6OrqyhMrw7Fs2TKg8LWl09JlxsJk98+hmOjrHS2j7Z/R3s+jvR8mk7T4i0Qiw5YZ6/0zGc+fYtovmWCm1KNFMiUsWbJEqKqa5zSWJhAICKvVKhobG4fkDQwMCKfTKU499VRx9tlnC5vNJrq7u4eUO3DggHC5XKKqqkps2bJlSP7u3bsLOugV62T26U9/WgDisccey0v/0Y9+lJll8Ktf/SqTnp5909jYKAYGBjLpw82+GWv7R8Ojjz4qkslkXlp3d7eorKwUdrtdRCKRvLz0bIszzjhjSN6BAwfyZvEcPHhQ2O12UVZWJnbu3JlJ7+zszEwzHWk2yqH6fzL6J00xjq4Tfb2jZbT9M9r7WYjR3Q8j9eF498FDDz0kAPGVr3xl2DJjvX8m+vlTbPslE4sUJTOMzZs3C0Acf/zxw5Y55ZRThn2QX3LJJUJRFGGxWApO0Utz7733CpvNJmw2m7jooovELbfcIq6++mpx0kknCVVVxQ9+8IMh3yn2AfnWW28Ju90uXC6X+MQnPiFuuukmcfrppwubzSbOO++8gg/xdJySxsZGcdNNN4lPf/r
2024-05-04 10:52:52 +00:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from statistics import mean\n",
"from datetime import datetime\n",
2024-05-06 06:04:45 +00:00
"from matplotlib.scale import ScaleBase, register_scale\n",
"from matplotlib.transforms import Transform\n",
"from matplotlib.axis import YAxis\n",
"\n",
2024-05-04 10:52:52 +00:00
"\n",
"c = db.cursor()\n",
"ratings = list(map(lambda r: r[0], c.execute(\"select distinct Rating from scores\")))\n",
"ratings.sort()\n",
"\n",
"for rating in ratings:\n",
" result = c.execute('select \"Song ID\", UNIXEPOCH(\"Time Played\"), \"Song Name\", Score from scores where Rating = ? order by \"Time Played\"', (rating,))\n",
2024-05-06 06:04:45 +00:00
" result = list(result)\n",
2024-05-04 10:52:52 +00:00
" scores = dict()\n",
" xs = []\n",
" ys = []\n",
" for record in result:\n",
2024-05-06 06:04:45 +00:00
" song_id = record[0]\n",
" scores[song_id] = 0\n",
" for record in result:\n",
2024-05-04 10:52:52 +00:00
" song_id, time_played, song_name, score = record\n",
" date = datetime.utcfromtimestamp(time_played)\n",
" scores[song_id] = score\n",
" values = list(scores.values())\n",
" avg = mean(values)\n",
2024-05-06 06:04:45 +00:00
" xs.append(date)\n",
" ys.append(avg)\n",
2024-05-04 10:52:52 +00:00
"\n",
" if xs and ys:\n",
" plt.plot(xs, ys, label=f\"Rating {rating}\")\n",
"\n",
"plt.legend()\n",
"plt.xticks(rotation=45, ha=\"right\")\n",
2024-05-06 06:04:45 +00:00
"plt.yscale('log')\n",
2024-05-04 10:52:52 +00:00
"plt.title(\"Average score for each level\")\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-05-06 06:04:45 +00:00
"execution_count": 4,
2024-05-02 03:05:34 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time Played\n",
2024-05-04 10:52:52 +00:00
"2024-03-04 29\n",
2024-05-06 06:04:45 +00:00
"2024-05-04 28\n",
2024-05-02 03:05:34 +00:00
"2024-04-14 24\n",
2024-05-06 06:04:45 +00:00
"2024-05-03 24\n",
"2024-05-01 23\n",
"2024-04-13 22\n",
2024-05-02 03:05:34 +00:00
"2024-04-18 20\n",
2024-05-06 06:04:45 +00:00
"2024-04-25 20\n",
"2024-04-20 18\n",
2024-05-02 03:05:34 +00:00
"2024-03-10 17\n",
"Name: Time Played, dtype: int64\n"
]
}
],
"source": [
"JST = pytz.timezone(\"Asia/Tokyo\")\n",
"CST = pytz.timezone(\"America/Chicago\")\n",
"\n",
"def to_jst_timestamp(s: str, format_str=\"%Y-%m-%d %H:%M:%S\"):\n",
" if type(s) is not str: return None\n",
" naive_dt = datetime.strptime(s, format_str)\n",
" jst_dt = JST.localize(naive_dt)\n",
" cst_dt = jst_dt.astimezone(CST)\n",
" return cst_dt\n",
"\n",
"times = data[\"Time Played\"]\n",
"times_mapped = times.map(to_jst_timestamp)\n",
"days_played = times_mapped.groupby(times_mapped.dt.date).count()\n",
"print(days_played.sort_values(ascending=False).head(10))"
]
},
{
"cell_type": "code",
2024-05-06 06:04:45 +00:00
"execution_count": 5,
2024-05-02 03:05:34 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-05-06 06:04:45 +00:00
" Clears Average Max Score Max Score Lamp Max Score Song\n",
"Rating \n",
"8 7 895073 996620 GFC 朧 (dj TAKA Remix)\n",
"9 25 918551 999650 PFC Why not\n",
"10 31 924433 992160 GFC 隅田川夏恋歌\n",
"11 44 899018 992520 GFC 朧\n",
"12 62 897328 987030 GFC MY SUMMER LOVE\n",
"13 74 843144 978430 GFC Struggle\n",
"14 125 801284 960440 FC FUNKY SUMMER BEACH\n",
"15 27 802587 917120 Clear Toy Box Factory\n",
"16 19 779613 862810 Clear Life is beautiful\n",
"17 3 724233 765430 Clear Elemental Creation\n"
2024-05-02 03:05:34 +00:00
]
}
],
"source": [
"records_by_level = data.loc[data[\"Lamp\"] != \"Fail\"].groupby(data[\"Rating\"])\n",
"num_clears_by_level = records_by_level[\"Score\"].count().rename(\"Clears\")\n",
"average_scores_by_level = records_by_level[\"Score\"].mean().round().astype(\"int\").rename(\"Average\")\n",
"def max_info(group):\n",
" max_idx = group[\"Score\"].idxmax()\n",
2024-05-02 03:21:29 +00:00
" return group.loc[max_idx][[\"Score\", \"Lamp\", \"Song Name\"]].rename({ \"Score\": \"Max Score\", \"Lamp\": \"Max Score Lamp\", \"Song Name\": \"Max Score Song\" })\n",
"max_score_by_level = records_by_level.apply(max_info)\n",
2024-05-02 03:05:34 +00:00
"result = pd.merge(num_clears_by_level, average_scores_by_level, on=\"Rating\")\n",
"result = pd.merge(result, max_score_by_level, on=\"Rating\")\n",
2024-05-02 03:21:29 +00:00
"with pd.option_context('expand_frame_repr', False):\n",
" print(result)"
2024-05-02 03:05:34 +00:00
]
},
{
"cell_type": "code",
2024-05-06 06:04:45 +00:00
"execution_count": 6,
2024-05-02 03:05:34 +00:00
"metadata": {},
2024-05-02 03:21:29 +00:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Song ID Song Name Difficulty Rating Score Grade Lamp Time Uploaded Time Played\n",
2024-05-06 06:04:45 +00:00
"44 1idIoi66ll806D8ddldOQi8bdiDO0Oil Struggle ESP 13 978430 AA+ GFC 2024-04-18 18:14:49 2024-04-18 18:05:47\n",
"128 9i6dOd608qb0IlqoDIPb8q1o8q1ddQQd FUNKY SUMMER BEACH ESP 14 960440 AA+ FC 2024-05-05 05:34:41 2024-05-05 05:22:53\n",
"59 1qPIiqqQo0P9dD90I11q90b0ooIidbPO CyberConnect ESP 15 903280 AA Clear 2024-05-05 02:40:07 2024-05-05 02:32:47\n",
"112 90lolio9qd6qo6Pl8oo69iqi81oiiQib I'm so Happy CSP 16 839540 A Clear 2024-05-05 02:19:22 2024-05-05 02:14:35\n",
"347 OiIOPd80d9PQQIbidO6ObioboO88OD9l Elemental Creation ESP 17 765430 B+ Clear 2024-05-05 05:34:41 2024-05-05 05:12:27\n"
2024-05-02 03:21:29 +00:00
]
}
],
"source": [
"# Gold 1\n",
"gold1scores = []\n",
"gold1scores.append(data[(data[\"Score\"] >= 975000) & (data[\"Rating\"] == 13)].head(1))\n",
"gold1scores.append(data[(data[\"Score\"] >= 925000) & (data[\"Rating\"] == 14)].head(1))\n",
"gold1scores.append(data[(data[\"Score\"] >= 875000) & (data[\"Rating\"] == 15)].head(1))\n",
"gold1scores.append(data[(data[\"Score\"] >= 825000) & (data[\"Rating\"] == 16)].head(1))\n",
"gold1scores.append(data[(data[\"Score\"] >= 750000) & (data[\"Rating\"] == 17)].head(1))\n",
"with pd.option_context('expand_frame_repr', False):\n",
" gold1scores = pd.concat(gold1scores)\n",
" print(gold1scores)"
]
2024-05-02 03:05:34 +00:00
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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",
2024-05-04 10:52:52 +00:00
"version": "3.11.7"
2024-05-02 03:05:34 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}