124 lines
4 KiB
Text
124 lines
4 KiB
Text
{
|
||
"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": 22,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
" Clears Average Song Name Score Lamp\n",
|
||
"Rating \n",
|
||
"8 7 895073 朧 (dj TAKA Remix) 996620 GFC\n",
|
||
"9 25 918551 Why not 999650 PFC\n",
|
||
"10 29 921425 隅田川夏恋歌 992160 GFC\n",
|
||
"11 40 896780 朧 992520 GFC\n",
|
||
"12 56 890122 MY SUMMER LOVE 987030 GFC\n",
|
||
"13 70 840879 Struggle 978430 GFC\n",
|
||
"14 121 799834 FUNKY SUMMER BEACH 943140 FC\n",
|
||
"15 26 798904 未来(ダ)FUTURE 898400 Clear\n",
|
||
"16 16 770314 Sword of Vengeance 861210 Clear\n",
|
||
"17 1 662870 PRANA+REVOLUTIONARY ADDICT (U1 DJ Mix) 662870 Clear\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]\n",
|
||
"max_score_by_level = records_by_level.apply(max_info)[[\"Score\", \"Lamp\", \"Song Name\"]]\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",
|
||
"print(result)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
}
|
||
],
|
||
"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
|
||
}
|