ddr-scores/summary.ipynb
2024-05-01 22:21:29 -05:00

148 lines
5.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from datetime import datetime, timezone, timedelta\n",
"import pytz\n",
"\n",
"with open(\"data/output.csv\", \"rb\") as f:\n",
" data = pd.read_csv(f, delimiter=\"\\t\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time Played\n",
"2024-03-04 30\n",
"2024-05-01 26\n",
"2024-04-13 26\n",
"2024-04-25 25\n",
"2024-04-14 24\n",
"2024-04-20 23\n",
"2024-04-18 20\n",
"2024-04-24 19\n",
"2024-03-05 17\n",
"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",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 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 29 921425 992160 GFC 隅田川夏恋歌\n",
"11 40 896780 992520 GFC 朧\n",
"12 56 890122 987030 GFC MY SUMMER LOVE\n",
"13 70 840879 978430 GFC Struggle\n",
"14 121 799834 943140 FC FUNKY SUMMER BEACH\n",
"15 26 798904 898400 Clear 未来FUTURE\n",
"16 16 770314 861210 Clear Sword of Vengeance\n",
"17 1 662870 662870 Clear PRANA+REVOLUTIONARY ADDICT (U1 DJ Mix)\n"
]
}
],
"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",
" 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",
"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",
"with pd.option_context('expand_frame_repr', False):\n",
" print(result)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Song ID Song Name Difficulty Rating Score Grade Lamp Time Uploaded Time Played\n",
"40 1idIoi66ll806D8ddldOQi8bdiDO0Oil Struggle ESP 13 978430 AA+ GFC 2024-04-18 18:14:49 2024-04-18 18:05:47\n",
"120 9i6dOd608qb0IlqoDIPb8q1o8q1ddQQd FUNKY SUMMER BEACH ESP 14 943140 AA FC 2024-05-01 22:11:00 2024-05-01 19:21:38\n",
"171 D686d06lO9IID8D0boPq0Pd8P89idO99 未来FUTURE ESP 15 898400 AA- Clear 2024-04-26 01:44:41 2024-04-26 01:40:06\n",
"205 ddqO1b1ldlQd6OOoQ1boPdoboDQqd9D8 Sword of Vengeance ESP 16 861210 A+ Clear 2024-05-01 18:42:28 2024-05-01 18:39:33\n"
]
}
],
"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)"
]
}
],
"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",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}