Commit
·
7b8bf24
1
Parent(s):
dcf28ff
analized dataset
Browse files- importYukiData.ipynb +1429 -11
importYukiData.ipynb
CHANGED
@@ -196,7 +196,7 @@
|
|
196 |
},
|
197 |
{
|
198 |
"cell_type": "code",
|
199 |
-
"execution_count":
|
200 |
"id": "449763c3",
|
201 |
"metadata": {},
|
202 |
"outputs": [
|
@@ -204,16 +204,7 @@
|
|
204 |
"name": "stdout",
|
205 |
"output_type": "stream",
|
206 |
"text": [
|
207 |
-
"
|
208 |
-
]
|
209 |
-
},
|
210 |
-
{
|
211 |
-
"ename": "SystemExit",
|
212 |
-
"evalue": "1",
|
213 |
-
"output_type": "error",
|
214 |
-
"traceback": [
|
215 |
-
"An exception has occurred, use %tb to see the full traceback.\n",
|
216 |
-
"\u001b[31mSystemExit\u001b[39m\u001b[31m:\u001b[39m 1\n"
|
217 |
]
|
218 |
}
|
219 |
],
|
@@ -355,6 +346,1433 @@
|
|
355 |
"\n",
|
356 |
"convert_headers(SRC, DST)\n"
|
357 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
],
|
360 |
"metadata": {
|
|
|
196 |
},
|
197 |
{
|
198 |
"cell_type": "code",
|
199 |
+
"execution_count": 12,
|
200 |
"id": "449763c3",
|
201 |
"metadata": {},
|
202 |
"outputs": [
|
|
|
204 |
"name": "stdout",
|
205 |
"output_type": "stream",
|
206 |
"text": [
|
207 |
+
"✅ activities.csv -> activities.csv へ変換完了\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
]
|
209 |
}
|
210 |
],
|
|
|
346 |
"\n",
|
347 |
"convert_headers(SRC, DST)\n"
|
348 |
]
|
349 |
+
},
|
350 |
+
{
|
351 |
+
"cell_type": "code",
|
352 |
+
"execution_count": 13,
|
353 |
+
"id": "48b01972",
|
354 |
+
"metadata": {},
|
355 |
+
"outputs": [],
|
356 |
+
"source": [
|
357 |
+
"df = pd.read_csv(\"StravaData/activities.csv\", parse_dates=[\"Activity Date\"])"
|
358 |
+
]
|
359 |
+
},
|
360 |
+
{
|
361 |
+
"cell_type": "code",
|
362 |
+
"execution_count": 14,
|
363 |
+
"id": "9cda0d2e",
|
364 |
+
"metadata": {},
|
365 |
+
"outputs": [
|
366 |
+
{
|
367 |
+
"ename": "FileNotFoundError",
|
368 |
+
"evalue": "[Errno 2] No such file or directory: 'activities_en.csv'",
|
369 |
+
"output_type": "error",
|
370 |
+
"traceback": [
|
371 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
372 |
+
"\u001b[31mFileNotFoundError\u001b[39m Traceback (most recent call last)",
|
373 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m df = \u001b[43mpd\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 2\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mactivities_en.csv\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 3\u001b[39m \u001b[43m \u001b[49m\u001b[43mparse_dates\u001b[49m\u001b[43m=\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mActivity Date\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# 日付列を datetime へ\u001b[39;49;00m\n\u001b[32m 4\u001b[39m \u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[43m=\u001b[49m\u001b[43m{\u001b[49m\n\u001b[32m 5\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mDistance\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfloat32\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 6\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mElapsed Time\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mint32\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 7\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mMoving Time\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mint32\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 8\u001b[39m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\n\u001b[32m 9\u001b[39m \u001b[43m)\u001b[49m\n",
|
374 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1026\u001b[39m, in \u001b[36mread_csv\u001b[39m\u001b[34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[39m\n\u001b[32m 1013\u001b[39m kwds_defaults = _refine_defaults_read(\n\u001b[32m 1014\u001b[39m dialect,\n\u001b[32m 1015\u001b[39m delimiter,\n\u001b[32m (...)\u001b[39m\u001b[32m 1022\u001b[39m dtype_backend=dtype_backend,\n\u001b[32m 1023\u001b[39m )\n\u001b[32m 1024\u001b[39m kwds.update(kwds_defaults)\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
|
375 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/parsers/readers.py:620\u001b[39m, in \u001b[36m_read\u001b[39m\u001b[34m(filepath_or_buffer, kwds)\u001b[39m\n\u001b[32m 617\u001b[39m _validate_names(kwds.get(\u001b[33m\"\u001b[39m\u001b[33mnames\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))\n\u001b[32m 619\u001b[39m \u001b[38;5;66;03m# Create the parser.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m620\u001b[39m parser = \u001b[43mTextFileReader\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 622\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m chunksize \u001b[38;5;129;01mor\u001b[39;00m iterator:\n\u001b[32m 623\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m parser\n",
|
376 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1620\u001b[39m, in \u001b[36mTextFileReader.__init__\u001b[39m\u001b[34m(self, f, engine, **kwds)\u001b[39m\n\u001b[32m 1617\u001b[39m \u001b[38;5;28mself\u001b[39m.options[\u001b[33m\"\u001b[39m\u001b[33mhas_index_names\u001b[39m\u001b[33m\"\u001b[39m] = kwds[\u001b[33m\"\u001b[39m\u001b[33mhas_index_names\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m 1619\u001b[39m \u001b[38;5;28mself\u001b[39m.handles: IOHandles | \u001b[38;5;28;01mNone\u001b[39;00m = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1620\u001b[39m \u001b[38;5;28mself\u001b[39m._engine = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_make_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m)\u001b[49m\n",
|
377 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1880\u001b[39m, in \u001b[36mTextFileReader._make_engine\u001b[39m\u001b[34m(self, f, engine)\u001b[39m\n\u001b[32m 1878\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[33m\"\u001b[39m\u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m mode:\n\u001b[32m 1879\u001b[39m mode += \u001b[33m\"\u001b[39m\u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m-> \u001b[39m\u001b[32m1880\u001b[39m \u001b[38;5;28mself\u001b[39m.handles = \u001b[43mget_handle\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1881\u001b[39m \u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1882\u001b[39m \u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1883\u001b[39m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mencoding\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1884\u001b[39m \u001b[43m \u001b[49m\u001b[43mcompression\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcompression\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1885\u001b[39m \u001b[43m \u001b[49m\u001b[43mmemory_map\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmemory_map\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1886\u001b[39m \u001b[43m \u001b[49m\u001b[43mis_text\u001b[49m\u001b[43m=\u001b[49m\u001b[43mis_text\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1887\u001b[39m \u001b[43m \u001b[49m\u001b[43merrors\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mencoding_errors\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstrict\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1888\u001b[39m \u001b[43m \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstorage_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1889\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1890\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m.handles \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1891\u001b[39m f = \u001b[38;5;28mself\u001b[39m.handles.handle\n",
|
378 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/common.py:873\u001b[39m, in \u001b[36mget_handle\u001b[39m\u001b[34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[39m\n\u001b[32m 868\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(handle, \u001b[38;5;28mstr\u001b[39m):\n\u001b[32m 869\u001b[39m \u001b[38;5;66;03m# Check whether the filename is to be opened in binary mode.\u001b[39;00m\n\u001b[32m 870\u001b[39m \u001b[38;5;66;03m# Binary mode does not support 'encoding' and 'newline'.\u001b[39;00m\n\u001b[32m 871\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m ioargs.encoding \u001b[38;5;129;01mand\u001b[39;00m \u001b[33m\"\u001b[39m\u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m ioargs.mode:\n\u001b[32m 872\u001b[39m \u001b[38;5;66;03m# Encoding\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m873\u001b[39m handle = \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[32m 874\u001b[39m \u001b[43m \u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 875\u001b[39m \u001b[43m \u001b[49m\u001b[43mioargs\u001b[49m\u001b[43m.\u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 876\u001b[39m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m=\u001b[49m\u001b[43mioargs\u001b[49m\u001b[43m.\u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 877\u001b[39m \u001b[43m \u001b[49m\u001b[43merrors\u001b[49m\u001b[43m=\u001b[49m\u001b[43merrors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 878\u001b[39m \u001b[43m \u001b[49m\u001b[43mnewline\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 879\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 880\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 881\u001b[39m \u001b[38;5;66;03m# Binary mode\u001b[39;00m\n\u001b[32m 882\u001b[39m handle = \u001b[38;5;28mopen\u001b[39m(handle, ioargs.mode)\n",
|
379 |
+
"\u001b[31mFileNotFoundError\u001b[39m: [Errno 2] No such file or directory: 'activities_en.csv'"
|
380 |
+
]
|
381 |
+
}
|
382 |
+
],
|
383 |
+
"source": [
|
384 |
+
"df = pd.read_csv(\n",
|
385 |
+
" \"activities_en.csv\",\n",
|
386 |
+
" parse_dates=[\"Activity Date\"], # 日付列を datetime へ\n",
|
387 |
+
" dtype={\n",
|
388 |
+
" \"Distance\": \"float32\",\n",
|
389 |
+
" \"Elapsed Time\": \"int32\",\n",
|
390 |
+
" \"Moving Time\": \"int32\",\n",
|
391 |
+
" }\n",
|
392 |
+
")"
|
393 |
+
]
|
394 |
+
},
|
395 |
+
{
|
396 |
+
"cell_type": "code",
|
397 |
+
"execution_count": 16,
|
398 |
+
"id": "79d66d2c",
|
399 |
+
"metadata": {},
|
400 |
+
"outputs": [
|
401 |
+
{
|
402 |
+
"data": {
|
403 |
+
"text/html": [
|
404 |
+
"<div>\n",
|
405 |
+
"<style scoped>\n",
|
406 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
407 |
+
" vertical-align: middle;\n",
|
408 |
+
" }\n",
|
409 |
+
"\n",
|
410 |
+
" .dataframe tbody tr th {\n",
|
411 |
+
" vertical-align: top;\n",
|
412 |
+
" }\n",
|
413 |
+
"\n",
|
414 |
+
" .dataframe thead th {\n",
|
415 |
+
" text-align: right;\n",
|
416 |
+
" }\n",
|
417 |
+
"</style>\n",
|
418 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
419 |
+
" <thead>\n",
|
420 |
+
" <tr style=\"text-align: right;\">\n",
|
421 |
+
" <th></th>\n",
|
422 |
+
" <th>Activity ID</th>\n",
|
423 |
+
" <th>Activity Date</th>\n",
|
424 |
+
" <th>Activity Name</th>\n",
|
425 |
+
" <th>Activity Type</th>\n",
|
426 |
+
" <th>Description</th>\n",
|
427 |
+
" <th>Elapsed Time</th>\n",
|
428 |
+
" <th>Distance</th>\n",
|
429 |
+
" <th>Max Heart Rate</th>\n",
|
430 |
+
" <th>Relative Effort</th>\n",
|
431 |
+
" <th>Commute</th>\n",
|
432 |
+
" <th>...</th>\n",
|
433 |
+
" <th>Activity Count</th>\n",
|
434 |
+
" <th>Step Count</th>\n",
|
435 |
+
" <th>Carbon Savings</th>\n",
|
436 |
+
" <th>Pool Length</th>\n",
|
437 |
+
" <th>Training Load</th>\n",
|
438 |
+
" <th>Intensity</th>\n",
|
439 |
+
" <th>Grade Adjusted Pace (Average)</th>\n",
|
440 |
+
" <th>Timer Time</th>\n",
|
441 |
+
" <th>Total Cycles</th>\n",
|
442 |
+
" <th>Media</th>\n",
|
443 |
+
" </tr>\n",
|
444 |
+
" </thead>\n",
|
445 |
+
" <tbody>\n",
|
446 |
+
" <tr>\n",
|
447 |
+
" <th>0</th>\n",
|
448 |
+
" <td>8280988291</td>\n",
|
449 |
+
" <td>2022-12-23 06:57:23</td>\n",
|
450 |
+
" <td>午後のランニング</td>\n",
|
451 |
+
" <td>ランニング</td>\n",
|
452 |
+
" <td>NaN</td>\n",
|
453 |
+
" <td>1530</td>\n",
|
454 |
+
" <td>4.62</td>\n",
|
455 |
+
" <td>NaN</td>\n",
|
456 |
+
" <td>NaN</td>\n",
|
457 |
+
" <td>False</td>\n",
|
458 |
+
" <td>...</td>\n",
|
459 |
+
" <td>NaN</td>\n",
|
460 |
+
" <td>NaN</td>\n",
|
461 |
+
" <td>NaN</td>\n",
|
462 |
+
" <td>NaN</td>\n",
|
463 |
+
" <td>NaN</td>\n",
|
464 |
+
" <td>NaN</td>\n",
|
465 |
+
" <td>NaN</td>\n",
|
466 |
+
" <td>NaN</td>\n",
|
467 |
+
" <td>NaN</td>\n",
|
468 |
+
" <td>NaN</td>\n",
|
469 |
+
" </tr>\n",
|
470 |
+
" <tr>\n",
|
471 |
+
" <th>1</th>\n",
|
472 |
+
" <td>8286585787</td>\n",
|
473 |
+
" <td>2022-12-24 09:57:04</td>\n",
|
474 |
+
" <td>夕方の水泳</td>\n",
|
475 |
+
" <td>水泳</td>\n",
|
476 |
+
" <td>NaN</td>\n",
|
477 |
+
" <td>4454</td>\n",
|
478 |
+
" <td>1150.00</td>\n",
|
479 |
+
" <td>NaN</td>\n",
|
480 |
+
" <td>NaN</td>\n",
|
481 |
+
" <td>False</td>\n",
|
482 |
+
" <td>...</td>\n",
|
483 |
+
" <td>NaN</td>\n",
|
484 |
+
" <td>NaN</td>\n",
|
485 |
+
" <td>NaN</td>\n",
|
486 |
+
" <td>NaN</td>\n",
|
487 |
+
" <td>NaN</td>\n",
|
488 |
+
" <td>NaN</td>\n",
|
489 |
+
" <td>NaN</td>\n",
|
490 |
+
" <td>NaN</td>\n",
|
491 |
+
" <td>NaN</td>\n",
|
492 |
+
" <td>NaN</td>\n",
|
493 |
+
" </tr>\n",
|
494 |
+
" <tr>\n",
|
495 |
+
" <th>2</th>\n",
|
496 |
+
" <td>8293206227</td>\n",
|
497 |
+
" <td>2022-12-26 10:42:37</td>\n",
|
498 |
+
" <td>夕方の水泳</td>\n",
|
499 |
+
" <td>水泳</td>\n",
|
500 |
+
" <td>NaN</td>\n",
|
501 |
+
" <td>4556</td>\n",
|
502 |
+
" <td>550.00</td>\n",
|
503 |
+
" <td>NaN</td>\n",
|
504 |
+
" <td>NaN</td>\n",
|
505 |
+
" <td>False</td>\n",
|
506 |
+
" <td>...</td>\n",
|
507 |
+
" <td>NaN</td>\n",
|
508 |
+
" <td>NaN</td>\n",
|
509 |
+
" <td>NaN</td>\n",
|
510 |
+
" <td>NaN</td>\n",
|
511 |
+
" <td>NaN</td>\n",
|
512 |
+
" <td>NaN</td>\n",
|
513 |
+
" <td>NaN</td>\n",
|
514 |
+
" <td>NaN</td>\n",
|
515 |
+
" <td>NaN</td>\n",
|
516 |
+
" <td>NaN</td>\n",
|
517 |
+
" </tr>\n",
|
518 |
+
" <tr>\n",
|
519 |
+
" <th>3</th>\n",
|
520 |
+
" <td>8314368113</td>\n",
|
521 |
+
" <td>2022-12-31 06:05:56</td>\n",
|
522 |
+
" <td>午後のライド</td>\n",
|
523 |
+
" <td>ライド</td>\n",
|
524 |
+
" <td>NaN</td>\n",
|
525 |
+
" <td>1897</td>\n",
|
526 |
+
" <td>9.10</td>\n",
|
527 |
+
" <td>NaN</td>\n",
|
528 |
+
" <td>NaN</td>\n",
|
529 |
+
" <td>False</td>\n",
|
530 |
+
" <td>...</td>\n",
|
531 |
+
" <td>NaN</td>\n",
|
532 |
+
" <td>NaN</td>\n",
|
533 |
+
" <td>NaN</td>\n",
|
534 |
+
" <td>NaN</td>\n",
|
535 |
+
" <td>NaN</td>\n",
|
536 |
+
" <td>NaN</td>\n",
|
537 |
+
" <td>NaN</td>\n",
|
538 |
+
" <td>NaN</td>\n",
|
539 |
+
" <td>NaN</td>\n",
|
540 |
+
" <td>NaN</td>\n",
|
541 |
+
" </tr>\n",
|
542 |
+
" <tr>\n",
|
543 |
+
" <th>4</th>\n",
|
544 |
+
" <td>8330224933</td>\n",
|
545 |
+
" <td>2023-01-01 06:53:06</td>\n",
|
546 |
+
" <td>午後のライド</td>\n",
|
547 |
+
" <td>ライド</td>\n",
|
548 |
+
" <td>NaN</td>\n",
|
549 |
+
" <td>1222</td>\n",
|
550 |
+
" <td>7.62</td>\n",
|
551 |
+
" <td>NaN</td>\n",
|
552 |
+
" <td>NaN</td>\n",
|
553 |
+
" <td>False</td>\n",
|
554 |
+
" <td>...</td>\n",
|
555 |
+
" <td>NaN</td>\n",
|
556 |
+
" <td>NaN</td>\n",
|
557 |
+
" <td>NaN</td>\n",
|
558 |
+
" <td>NaN</td>\n",
|
559 |
+
" <td>NaN</td>\n",
|
560 |
+
" <td>NaN</td>\n",
|
561 |
+
" <td>NaN</td>\n",
|
562 |
+
" <td>NaN</td>\n",
|
563 |
+
" <td>NaN</td>\n",
|
564 |
+
" <td>NaN</td>\n",
|
565 |
+
" </tr>\n",
|
566 |
+
" </tbody>\n",
|
567 |
+
"</table>\n",
|
568 |
+
"<p>5 rows × 94 columns</p>\n",
|
569 |
+
"</div>"
|
570 |
+
],
|
571 |
+
"text/plain": [
|
572 |
+
" Activity ID Activity Date Activity Name Activity Type Description \\\n",
|
573 |
+
"0 8280988291 2022-12-23 06:57:23 午後のランニング ランニング NaN \n",
|
574 |
+
"1 8286585787 2022-12-24 09:57:04 夕方の水泳 水泳 NaN \n",
|
575 |
+
"2 8293206227 2022-12-26 10:42:37 夕方の水泳 水泳 NaN \n",
|
576 |
+
"3 8314368113 2022-12-31 06:05:56 午後のライド ライド NaN \n",
|
577 |
+
"4 8330224933 2023-01-01 06:53:06 午後のライド ライド NaN \n",
|
578 |
+
"\n",
|
579 |
+
" Elapsed Time Distance Max Heart Rate Relative Effort Commute ... \\\n",
|
580 |
+
"0 1530 4.62 NaN NaN False ... \n",
|
581 |
+
"1 4454 1150.00 NaN NaN False ... \n",
|
582 |
+
"2 4556 550.00 NaN NaN False ... \n",
|
583 |
+
"3 1897 9.10 NaN NaN False ... \n",
|
584 |
+
"4 1222 7.62 NaN NaN False ... \n",
|
585 |
+
"\n",
|
586 |
+
" Activity Count Step Count Carbon Savings Pool Length Training Load \\\n",
|
587 |
+
"0 NaN NaN NaN NaN NaN \n",
|
588 |
+
"1 NaN NaN NaN NaN NaN \n",
|
589 |
+
"2 NaN NaN NaN NaN NaN \n",
|
590 |
+
"3 NaN NaN NaN NaN NaN \n",
|
591 |
+
"4 NaN NaN NaN NaN NaN \n",
|
592 |
+
"\n",
|
593 |
+
" Intensity Grade Adjusted Pace (Average) Timer Time Total Cycles Media \n",
|
594 |
+
"0 NaN NaN NaN NaN NaN \n",
|
595 |
+
"1 NaN NaN NaN NaN NaN \n",
|
596 |
+
"2 NaN NaN NaN NaN NaN \n",
|
597 |
+
"3 NaN NaN NaN NaN NaN \n",
|
598 |
+
"4 NaN NaN NaN NaN NaN \n",
|
599 |
+
"\n",
|
600 |
+
"[5 rows x 94 columns]"
|
601 |
+
]
|
602 |
+
},
|
603 |
+
"execution_count": 16,
|
604 |
+
"metadata": {},
|
605 |
+
"output_type": "execute_result"
|
606 |
+
}
|
607 |
+
],
|
608 |
+
"source": [
|
609 |
+
"df = pd.read_csv(\n",
|
610 |
+
" \"/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/StravaData/activities.csv\",\n",
|
611 |
+
" parse_dates=[\"Activity Date\"],\n",
|
612 |
+
" thousands=\",\", # ← カンマを数値から自動除去\n",
|
613 |
+
" low_memory=False # dtype 混在警告を抑制したい場合\n",
|
614 |
+
")\n",
|
615 |
+
"\n",
|
616 |
+
"# 別セルで型を落とす(省メモリ化)\n",
|
617 |
+
"df = df.astype({\n",
|
618 |
+
" \"Distance\": \"float32\",\n",
|
619 |
+
" \"Elapsed Time\": \"int32\",\n",
|
620 |
+
" \"Moving Time\": \"int32\"\n",
|
621 |
+
"})\n",
|
622 |
+
"\n",
|
623 |
+
"df.head()"
|
624 |
+
]
|
625 |
+
},
|
626 |
+
{
|
627 |
+
"cell_type": "code",
|
628 |
+
"execution_count": 17,
|
629 |
+
"id": "67927c66",
|
630 |
+
"metadata": {},
|
631 |
+
"outputs": [
|
632 |
+
{
|
633 |
+
"ename": "KeyError",
|
634 |
+
"evalue": "'moving_hr'",
|
635 |
+
"output_type": "error",
|
636 |
+
"traceback": [
|
637 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
638 |
+
"\u001b[31mKeyError\u001b[39m Traceback (most recent call last)",
|
639 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/indexes/base.py:3805\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m 3804\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m3805\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_engine\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 3806\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
|
640 |
+
"\u001b[36mFile \u001b[39m\u001b[32mindex.pyx:167\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
|
641 |
+
"\u001b[36mFile \u001b[39m\u001b[32mindex.pyx:196\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
|
642 |
+
"\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/hashtable_class_helper.pxi:7081\u001b[39m, in \u001b[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[39m\u001b[34m()\u001b[39m\n",
|
643 |
+
"\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/hashtable_class_helper.pxi:7089\u001b[39m, in \u001b[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[39m\u001b[34m()\u001b[39m\n",
|
644 |
+
"\u001b[31mKeyError\u001b[39m: 'moving_hr'",
|
645 |
+
"\nThe above exception was the direct cause of the following exception:\n",
|
646 |
+
"\u001b[31mKeyError\u001b[39m Traceback (most recent call last)",
|
647 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[17]\u001b[39m\u001b[32m, line 16\u001b[39m\n\u001b[32m 11\u001b[39m df[\u001b[33m\"\u001b[39m\u001b[33mtraining_category\u001b[39m\u001b[33m\"\u001b[39m] = pd.cut(\n\u001b[32m 12\u001b[39m df[\u001b[33m\"\u001b[39m\u001b[33mintensity_level\u001b[39m\u001b[33m\"\u001b[39m], bins=bins, labels=labels, right=\u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[32m 13\u001b[39m ).cat.add_categories(\u001b[33m\"\u001b[39m\u001b[33mNoHR\u001b[39m\u001b[33m\"\u001b[39m).fillna(\u001b[33m\"\u001b[39m\u001b[33mNoHR\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 15\u001b[39m \u001b[38;5;66;03m# 3) TRIMP\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m16\u001b[39m df[\u001b[33m\"\u001b[39m\u001b[33mtrimp\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[43mdf\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmoving_hr\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m * df[\u001b[33m\"\u001b[39m\u001b[33mintensity_level\u001b[39m\u001b[33m\"\u001b[39m] * \u001b[32m50\u001b[39m\n\u001b[32m 18\u001b[39m \u001b[38;5;66;03m# 4) 保存\u001b[39;00m\n\u001b[32m 19\u001b[39m df.to_parquet(\u001b[33m\"\u001b[39m\u001b[33mstrava_master_enhanced.parquet\u001b[39m\u001b[33m\"\u001b[39m, index=\u001b[38;5;28;01mFalse\u001b[39;00m)\n",
|
648 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/frame.py:4102\u001b[39m, in \u001b[36mDataFrame.__getitem__\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m 4100\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.columns.nlevels > \u001b[32m1\u001b[39m:\n\u001b[32m 4101\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._getitem_multilevel(key)\n\u001b[32m-> \u001b[39m\u001b[32m4102\u001b[39m indexer = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mcolumns\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 4103\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[32m 4104\u001b[39m indexer = [indexer]\n",
|
649 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/indexes/base.py:3812\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m 3807\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(casted_key, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[32m 3808\u001b[39m \u001b[38;5;28misinstance\u001b[39m(casted_key, abc.Iterable)\n\u001b[32m 3809\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28many\u001b[39m(\u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m casted_key)\n\u001b[32m 3810\u001b[39m ):\n\u001b[32m 3811\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m InvalidIndexError(key)\n\u001b[32m-> \u001b[39m\u001b[32m3812\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[34;01merr\u001b[39;00m\n\u001b[32m 3813\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[32m 3814\u001b[39m \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[32m 3815\u001b[39m \u001b[38;5;66;03m# InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[32m 3816\u001b[39m \u001b[38;5;66;03m# the TypeError.\u001b[39;00m\n\u001b[32m 3817\u001b[39m \u001b[38;5;28mself\u001b[39m._check_indexing_error(key)\n",
|
650 |
+
"\u001b[31mKeyError\u001b[39m: 'moving_hr'"
|
651 |
+
]
|
652 |
+
}
|
653 |
+
],
|
654 |
+
"source": [
|
655 |
+
"# 0) 前ステップで df に distance_km, moving_hr などが出来ている前提\n",
|
656 |
+
"import pandas as pd\n",
|
657 |
+
"LTHR = 165 # 自分で設定\n",
|
658 |
+
"\n",
|
659 |
+
"# 1) intensity_level\n",
|
660 |
+
"df[\"intensity_level\"] = (df[\"Average Heart Rate\"] / LTHR).round(2)\n",
|
661 |
+
"\n",
|
662 |
+
"# 2) training_category\n",
|
663 |
+
"bins = [0, .79, .89, .95, 1.10]\n",
|
664 |
+
"labels = [\"Z1-2\", \"Z3\", \"Z4\", \"Z5\"]\n",
|
665 |
+
"df[\"training_category\"] = pd.cut(\n",
|
666 |
+
" df[\"intensity_level\"], bins=bins, labels=labels, right=False\n",
|
667 |
+
").cat.add_categories(\"NoHR\").fillna(\"NoHR\")\n",
|
668 |
+
"\n",
|
669 |
+
"# 3) TRIMP\n",
|
670 |
+
"df[\"trimp\"] = df[\"moving_hr\"] * df[\"intensity_level\"] * 50\n",
|
671 |
+
"\n",
|
672 |
+
"# 4) 保存\n",
|
673 |
+
"df.to_parquet(\"strava_master_enhanced.parquet\", index=False)\n"
|
674 |
+
]
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"cell_type": "code",
|
678 |
+
"execution_count": 18,
|
679 |
+
"id": "a95f5212",
|
680 |
+
"metadata": {},
|
681 |
+
"outputs": [
|
682 |
+
{
|
683 |
+
"name": "stdout",
|
684 |
+
"output_type": "stream",
|
685 |
+
"text": [
|
686 |
+
"['Activity ID', 'Activity Date', 'Activity Name', 'Activity Type', 'Description', 'Elapsed Time', 'Distance', 'Max Heart Rate', 'Relative Effort', 'Commute', 'Activity Private Notes', 'Gear', 'Filename', 'Athlete Weight', 'Bike Weight', 'Elapsed Time.1', 'Moving Time', 'Distance.1', 'Max Speed', 'Average Speed', 'Elevation Gain', 'Elevation Loss', 'Min Elevation', 'Max Elevation', 'Max Grade', 'Average Grade', 'Average Positive Grade', 'Average Negative Grade', 'Max Cadence', 'Average Cadence', 'Max Heart Rate.1', 'Average Heart Rate', 'Max Power', 'Average Power', 'Calories', 'Max Temperature', 'Average Temperature', 'Relative Effort.1', 'Total Work', 'Number of Runs', 'Uphill Time', 'Downhill Time', 'Other Time', 'Perceived Exertion', 'Device Type', 'Start Time', 'Weighted Average Power', 'Power Count', 'Perceived Exertion Used', 'Perceived Relative Effort', 'Commute.1', 'Total Weight', 'Weather Observed', 'Grade Adjusted Pace', 'Observation Time', 'Weather', 'Average Temperature.1', 'Apparent Temperature', 'Dew Point', 'Humidity', 'Pressure', 'Wind Speed', 'Wind Gust', 'Wind Bearing', 'Precipitation', 'Sunset Time', 'Sunrise Time', 'Moon Phase', '自転車', 'Gear.1', 'Precipitation Probability', 'Precipitation Type', 'Cloud Cover', 'Visibility', 'UV Index', 'Ozone', 'Jump Count', 'Total Grit', 'Average Flow', 'Flagged', 'Average Elapsed Speed', 'Dirt Distance', 'Newly Explored Distance', 'Newly Explored Dirt Distance', 'Activity Count', 'Step Count', 'Carbon Savings', 'Pool Length', 'Training Load', 'Intensity', 'Grade Adjusted Pace (Average)', 'Timer Time', 'Total Cycles', 'Media', 'intensity_level', 'training_category']\n"
|
687 |
+
]
|
688 |
+
}
|
689 |
+
],
|
690 |
+
"source": [
|
691 |
+
"print(df.columns.tolist())\n"
|
692 |
+
]
|
693 |
+
},
|
694 |
+
{
|
695 |
+
"cell_type": "code",
|
696 |
+
"execution_count": 19,
|
697 |
+
"id": "4ac5e0fa",
|
698 |
+
"metadata": {},
|
699 |
+
"outputs": [],
|
700 |
+
"source": [
|
701 |
+
"# Moving Time は秒なので h に変換\n",
|
702 |
+
"df[\"moving_hr\"] = pd.to_numeric(df[\"Moving Time\"], errors=\"coerce\") / 3600\n"
|
703 |
+
]
|
704 |
+
},
|
705 |
+
{
|
706 |
+
"cell_type": "code",
|
707 |
+
"execution_count": 20,
|
708 |
+
"id": "23f8cf4d",
|
709 |
+
"metadata": {},
|
710 |
+
"outputs": [],
|
711 |
+
"source": [
|
712 |
+
"# --- moving_hr を作ってから一気に ---\n",
|
713 |
+
"LTHR = 165\n",
|
714 |
+
"\n",
|
715 |
+
"df = (\n",
|
716 |
+
" df\n",
|
717 |
+
" .assign(\n",
|
718 |
+
" moving_hr = pd.to_numeric(df[\"Moving Time\"], errors=\"coerce\") / 3600,\n",
|
719 |
+
" intensity_level = lambda x: (x[\"Average Heart Rate\"] / LTHR).round(2)\n",
|
720 |
+
" )\n",
|
721 |
+
")\n",
|
722 |
+
"\n",
|
723 |
+
"bins = [0, .79, .89, .95, 1.10]\n",
|
724 |
+
"labels = [\"Z1-2\", \"Z3\", \"Z4\", \"Z5\"]\n",
|
725 |
+
"df[\"training_category\"] = pd.cut(\n",
|
726 |
+
" df[\"intensity_level\"], bins=bins, labels=labels, right=False\n",
|
727 |
+
").cat.add_categories(\"NoHR\").fillna(\"NoHR\")\n",
|
728 |
+
"\n",
|
729 |
+
"df[\"trimp\"] = df[\"moving_hr\"] * df[\"intensity_level\"] * 50\n"
|
730 |
+
]
|
731 |
+
},
|
732 |
+
{
|
733 |
+
"cell_type": "code",
|
734 |
+
"execution_count": 22,
|
735 |
+
"id": "1a845f19",
|
736 |
+
"metadata": {},
|
737 |
+
"outputs": [
|
738 |
+
{
|
739 |
+
"ename": "ImportError",
|
740 |
+
"evalue": "Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'.\nA suitable version of pyarrow or fastparquet is required for parquet support.\nTrying to import the above resulted in these errors:\n - Missing optional dependency 'pyarrow'. pyarrow is required for parquet support. Use pip or conda to install pyarrow.\n - Missing optional dependency 'fastparquet'. fastparquet is required for parquet support. Use pip or conda to install fastparquet.",
|
741 |
+
"output_type": "error",
|
742 |
+
"traceback": [
|
743 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
744 |
+
"\u001b[31mImportError\u001b[39m Traceback (most recent call last)",
|
745 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[22]\u001b[39m\u001b[32m, line 11\u001b[39m\n\u001b[32m 8\u001b[39m \u001b[38;5;66;03m# ----------------------------------------\u001b[39;00m\n\u001b[32m 9\u001b[39m \u001b[38;5;66;03m# 1) Parquet 保存(高速・省サイズ)\u001b[39;00m\n\u001b[32m 10\u001b[39m parq_path = out_dir / \u001b[33m\"\u001b[39m\u001b[33mstrava_master_enhanced.parquet\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m---> \u001b[39m\u001b[32m11\u001b[39m \u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mto_parquet\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparq_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindex\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[32m 12\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m✅ Parquet 保存完了: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparq_path\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m 14\u001b[39m \u001b[38;5;66;03m# 2) CSV も欲しい場合(任意)\u001b[39;00m\n",
|
746 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/util/_decorators.py:333\u001b[39m, in \u001b[36mdeprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper\u001b[39m\u001b[34m(*args, **kwargs)\u001b[39m\n\u001b[32m 327\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(args) > num_allow_args:\n\u001b[32m 328\u001b[39m warnings.warn(\n\u001b[32m 329\u001b[39m msg.format(arguments=_format_argument_list(allow_args)),\n\u001b[32m 330\u001b[39m \u001b[38;5;167;01mFutureWarning\u001b[39;00m,\n\u001b[32m 331\u001b[39m stacklevel=find_stack_level(),\n\u001b[32m 332\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m333\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
747 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/frame.py:3113\u001b[39m, in \u001b[36mDataFrame.to_parquet\u001b[39m\u001b[34m(self, path, engine, compression, index, partition_cols, storage_options, **kwargs)\u001b[39m\n\u001b[32m 3032\u001b[39m \u001b[38;5;250m\u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 3033\u001b[39m \u001b[33;03mWrite a DataFrame to the binary parquet format.\u001b[39;00m\n\u001b[32m 3034\u001b[39m \n\u001b[32m (...)\u001b[39m\u001b[32m 3109\u001b[39m \u001b[33;03m>>> content = f.read()\u001b[39;00m\n\u001b[32m 3110\u001b[39m \u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 3111\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[34;01mpandas\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mio\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mparquet\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m to_parquet\n\u001b[32m-> \u001b[39m\u001b[32m3113\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mto_parquet\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 3114\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 3115\u001b[39m \u001b[43m \u001b[49m\u001b[43mpath\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3116\u001b[39m \u001b[43m \u001b[49m\u001b[43mengine\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3117\u001b[39m \u001b[43m \u001b[49m\u001b[43mcompression\u001b[49m\u001b[43m=\u001b[49m\u001b[43mcompression\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3118\u001b[39m \u001b[43m \u001b[49m\u001b[43mindex\u001b[49m\u001b[43m=\u001b[49m\u001b[43mindex\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3119\u001b[39m \u001b[43m \u001b[49m\u001b[43mpartition_cols\u001b[49m\u001b[43m=\u001b[49m\u001b[43mpartition_cols\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3120\u001b[39m \u001b[43m \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3121\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 3122\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
|
748 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/parquet.py:476\u001b[39m, in \u001b[36mto_parquet\u001b[39m\u001b[34m(df, path, engine, compression, index, storage_options, partition_cols, filesystem, **kwargs)\u001b[39m\n\u001b[32m 474\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(partition_cols, \u001b[38;5;28mstr\u001b[39m):\n\u001b[32m 475\u001b[39m partition_cols = [partition_cols]\n\u001b[32m--> \u001b[39m\u001b[32m476\u001b[39m impl = \u001b[43mget_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 478\u001b[39m path_or_buf: FilePath | WriteBuffer[\u001b[38;5;28mbytes\u001b[39m] = io.BytesIO() \u001b[38;5;28;01mif\u001b[39;00m path \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m path\n\u001b[32m 480\u001b[39m impl.write(\n\u001b[32m 481\u001b[39m df,\n\u001b[32m 482\u001b[39m path_or_buf,\n\u001b[32m (...)\u001b[39m\u001b[32m 488\u001b[39m **kwargs,\n\u001b[32m 489\u001b[39m )\n",
|
749 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/io/parquet.py:67\u001b[39m, in \u001b[36mget_engine\u001b[39m\u001b[34m(engine)\u001b[39m\n\u001b[32m 64\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[32m 65\u001b[39m error_msgs += \u001b[33m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m - \u001b[39m\u001b[33m\"\u001b[39m + \u001b[38;5;28mstr\u001b[39m(err)\n\u001b[32m---> \u001b[39m\u001b[32m67\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m(\n\u001b[32m 68\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mUnable to find a usable engine; \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 69\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mtried using: \u001b[39m\u001b[33m'\u001b[39m\u001b[33mpyarrow\u001b[39m\u001b[33m'\u001b[39m\u001b[33m, \u001b[39m\u001b[33m'\u001b[39m\u001b[33mfastparquet\u001b[39m\u001b[33m'\u001b[39m\u001b[33m.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 70\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mA suitable version of \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 71\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mpyarrow or fastparquet is required for parquet \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 72\u001b[39m \u001b[33m\"\u001b[39m\u001b[33msupport.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 73\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mTrying to import the above resulted in these errors:\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 74\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00merror_msgs\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 75\u001b[39m )\n\u001b[32m 77\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m engine == \u001b[33m\"\u001b[39m\u001b[33mpyarrow\u001b[39m\u001b[33m\"\u001b[39m:\n\u001b[32m 78\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m PyArrowImpl()\n",
|
750 |
+
"\u001b[31mImportError\u001b[39m: Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'.\nA suitable version of pyarrow or fastparquet is required for parquet support.\nTrying to import the above resulted in these errors:\n - Missing optional dependency 'pyarrow'. pyarrow is required for parquet support. Use pip or conda to install pyarrow.\n - Missing optional dependency 'fastparquet'. fastparquet is required for parquet support. Use pip or conda to install fastparquet."
|
751 |
+
]
|
752 |
+
}
|
753 |
+
],
|
754 |
+
"source": [
|
755 |
+
"from pathlib import Path\n",
|
756 |
+
"\n",
|
757 |
+
"# ----------------------------------------\n",
|
758 |
+
"# 0) 保存先ディレクトリを用意(無ければ作成)\n",
|
759 |
+
"out_dir = Path(\"/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset\")\n",
|
760 |
+
"out_dir.mkdir(exist_ok=True)\n",
|
761 |
+
"\n",
|
762 |
+
"# ----------------------------------------\n",
|
763 |
+
"# 1) Parquet 保存(高速・省サイズ)\n",
|
764 |
+
"parq_path = out_dir / \"strava_master_enhanced.parquet\"\n",
|
765 |
+
"df.to_parquet(parq_path, index=False)\n",
|
766 |
+
"print(f\"✅ Parquet 保存完了: {parq_path}\")\n",
|
767 |
+
"\n",
|
768 |
+
"# 2) CSV も欲しい場合(任意)\n",
|
769 |
+
"csv_path = out_dir / \"strava_master_enhanced.csv\"\n",
|
770 |
+
"df.to_csv(csv_path, index=False)\n",
|
771 |
+
"print(f\"✅ CSV 保存完了: {csv_path}\")\n"
|
772 |
+
]
|
773 |
+
},
|
774 |
+
{
|
775 |
+
"cell_type": "code",
|
776 |
+
"execution_count": 23,
|
777 |
+
"id": "f01f5685",
|
778 |
+
"metadata": {},
|
779 |
+
"outputs": [],
|
780 |
+
"source": [
|
781 |
+
"!pip install --quiet pyarrow"
|
782 |
+
]
|
783 |
+
},
|
784 |
+
{
|
785 |
+
"cell_type": "code",
|
786 |
+
"execution_count": 24,
|
787 |
+
"id": "c689d216",
|
788 |
+
"metadata": {},
|
789 |
+
"outputs": [
|
790 |
+
{
|
791 |
+
"name": "stdout",
|
792 |
+
"output_type": "stream",
|
793 |
+
"text": [
|
794 |
+
"✅ Parquet 保存完了: /Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset/strava_master_enhanced.parquet\n",
|
795 |
+
"✅ CSV 保存完了: /Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset/strava_master_enhanced.csv\n"
|
796 |
+
]
|
797 |
+
}
|
798 |
+
],
|
799 |
+
"source": [
|
800 |
+
"from pathlib import Path\n",
|
801 |
+
"\n",
|
802 |
+
"# ----------------------------------------\n",
|
803 |
+
"# 0) 保存先ディレクトリを用意(無ければ作成)\n",
|
804 |
+
"out_dir = Path(\"/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset\")\n",
|
805 |
+
"out_dir.mkdir(exist_ok=True)\n",
|
806 |
+
"\n",
|
807 |
+
"# ----------------------------------------\n",
|
808 |
+
"# 1) Parquet 保存(高速・省サイズ)\n",
|
809 |
+
"parq_path = out_dir / \"strava_master_enhanced.parquet\"\n",
|
810 |
+
"df.to_parquet(parq_path, index=False)\n",
|
811 |
+
"print(f\"✅ Parquet 保存完了: {parq_path}\")\n",
|
812 |
+
"\n",
|
813 |
+
"# 2) CSV も欲しい場合(任意)\n",
|
814 |
+
"csv_path = out_dir / \"strava_master_enhanced.csv\"\n",
|
815 |
+
"df.to_csv(csv_path, index=False)\n",
|
816 |
+
"print(f\"✅ CSV 保存完了: {csv_path}\")\n"
|
817 |
+
]
|
818 |
+
},
|
819 |
+
{
|
820 |
+
"cell_type": "code",
|
821 |
+
"execution_count": 25,
|
822 |
+
"id": "9bd3bb5d",
|
823 |
+
"metadata": {},
|
824 |
+
"outputs": [
|
825 |
+
{
|
826 |
+
"name": "stdout",
|
827 |
+
"output_type": "stream",
|
828 |
+
"text": [
|
829 |
+
"(474, 98) rows x columns\n"
|
830 |
+
]
|
831 |
+
},
|
832 |
+
{
|
833 |
+
"data": {
|
834 |
+
"text/html": [
|
835 |
+
"<div>\n",
|
836 |
+
"<style scoped>\n",
|
837 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
838 |
+
" vertical-align: middle;\n",
|
839 |
+
" }\n",
|
840 |
+
"\n",
|
841 |
+
" .dataframe tbody tr th {\n",
|
842 |
+
" vertical-align: top;\n",
|
843 |
+
" }\n",
|
844 |
+
"\n",
|
845 |
+
" .dataframe thead th {\n",
|
846 |
+
" text-align: right;\n",
|
847 |
+
" }\n",
|
848 |
+
"</style>\n",
|
849 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
850 |
+
" <thead>\n",
|
851 |
+
" <tr style=\"text-align: right;\">\n",
|
852 |
+
" <th></th>\n",
|
853 |
+
" <th>Activity ID</th>\n",
|
854 |
+
" <th>Activity Date</th>\n",
|
855 |
+
" <th>Activity Name</th>\n",
|
856 |
+
" <th>Activity Type</th>\n",
|
857 |
+
" <th>Description</th>\n",
|
858 |
+
" <th>Elapsed Time</th>\n",
|
859 |
+
" <th>Distance</th>\n",
|
860 |
+
" <th>Max Heart Rate</th>\n",
|
861 |
+
" <th>Relative Effort</th>\n",
|
862 |
+
" <th>Commute</th>\n",
|
863 |
+
" <th>...</th>\n",
|
864 |
+
" <th>Training Load</th>\n",
|
865 |
+
" <th>Intensity</th>\n",
|
866 |
+
" <th>Grade Adjusted Pace (Average)</th>\n",
|
867 |
+
" <th>Timer Time</th>\n",
|
868 |
+
" <th>Total Cycles</th>\n",
|
869 |
+
" <th>Media</th>\n",
|
870 |
+
" <th>intensity_level</th>\n",
|
871 |
+
" <th>training_category</th>\n",
|
872 |
+
" <th>moving_hr</th>\n",
|
873 |
+
" <th>trimp</th>\n",
|
874 |
+
" </tr>\n",
|
875 |
+
" </thead>\n",
|
876 |
+
" <tbody>\n",
|
877 |
+
" <tr>\n",
|
878 |
+
" <th>0</th>\n",
|
879 |
+
" <td>8280988291</td>\n",
|
880 |
+
" <td>2022-12-23 06:57:23</td>\n",
|
881 |
+
" <td>午後のランニング</td>\n",
|
882 |
+
" <td>ランニング</td>\n",
|
883 |
+
" <td>NaN</td>\n",
|
884 |
+
" <td>1530</td>\n",
|
885 |
+
" <td>4.62</td>\n",
|
886 |
+
" <td>NaN</td>\n",
|
887 |
+
" <td>NaN</td>\n",
|
888 |
+
" <td>False</td>\n",
|
889 |
+
" <td>...</td>\n",
|
890 |
+
" <td>NaN</td>\n",
|
891 |
+
" <td>NaN</td>\n",
|
892 |
+
" <td>NaN</td>\n",
|
893 |
+
" <td>NaN</td>\n",
|
894 |
+
" <td>NaN</td>\n",
|
895 |
+
" <td>NaN</td>\n",
|
896 |
+
" <td>NaN</td>\n",
|
897 |
+
" <td>NoHR</td>\n",
|
898 |
+
" <td>0.421944</td>\n",
|
899 |
+
" <td>NaN</td>\n",
|
900 |
+
" </tr>\n",
|
901 |
+
" <tr>\n",
|
902 |
+
" <th>1</th>\n",
|
903 |
+
" <td>8286585787</td>\n",
|
904 |
+
" <td>2022-12-24 09:57:04</td>\n",
|
905 |
+
" <td>夕方の水泳</td>\n",
|
906 |
+
" <td>水泳</td>\n",
|
907 |
+
" <td>NaN</td>\n",
|
908 |
+
" <td>4454</td>\n",
|
909 |
+
" <td>1150.00</td>\n",
|
910 |
+
" <td>NaN</td>\n",
|
911 |
+
" <td>NaN</td>\n",
|
912 |
+
" <td>False</td>\n",
|
913 |
+
" <td>...</td>\n",
|
914 |
+
" <td>NaN</td>\n",
|
915 |
+
" <td>NaN</td>\n",
|
916 |
+
" <td>NaN</td>\n",
|
917 |
+
" <td>NaN</td>\n",
|
918 |
+
" <td>NaN</td>\n",
|
919 |
+
" <td>NaN</td>\n",
|
920 |
+
" <td>NaN</td>\n",
|
921 |
+
" <td>NoHR</td>\n",
|
922 |
+
" <td>0.446111</td>\n",
|
923 |
+
" <td>NaN</td>\n",
|
924 |
+
" </tr>\n",
|
925 |
+
" <tr>\n",
|
926 |
+
" <th>2</th>\n",
|
927 |
+
" <td>8293206227</td>\n",
|
928 |
+
" <td>2022-12-26 10:42:37</td>\n",
|
929 |
+
" <td>夕方の水泳</td>\n",
|
930 |
+
" <td>水泳</td>\n",
|
931 |
+
" <td>NaN</td>\n",
|
932 |
+
" <td>4556</td>\n",
|
933 |
+
" <td>550.00</td>\n",
|
934 |
+
" <td>NaN</td>\n",
|
935 |
+
" <td>NaN</td>\n",
|
936 |
+
" <td>False</td>\n",
|
937 |
+
" <td>...</td>\n",
|
938 |
+
" <td>NaN</td>\n",
|
939 |
+
" <td>NaN</td>\n",
|
940 |
+
" <td>NaN</td>\n",
|
941 |
+
" <td>NaN</td>\n",
|
942 |
+
" <td>NaN</td>\n",
|
943 |
+
" <td>NaN</td>\n",
|
944 |
+
" <td>NaN</td>\n",
|
945 |
+
" <td>NoHR</td>\n",
|
946 |
+
" <td>0.400278</td>\n",
|
947 |
+
" <td>NaN</td>\n",
|
948 |
+
" </tr>\n",
|
949 |
+
" <tr>\n",
|
950 |
+
" <th>3</th>\n",
|
951 |
+
" <td>8314368113</td>\n",
|
952 |
+
" <td>2022-12-31 06:05:56</td>\n",
|
953 |
+
" <td>午後のライド</td>\n",
|
954 |
+
" <td>ライド</td>\n",
|
955 |
+
" <td>NaN</td>\n",
|
956 |
+
" <td>1897</td>\n",
|
957 |
+
" <td>9.10</td>\n",
|
958 |
+
" <td>NaN</td>\n",
|
959 |
+
" <td>NaN</td>\n",
|
960 |
+
" <td>False</td>\n",
|
961 |
+
" <td>...</td>\n",
|
962 |
+
" <td>NaN</td>\n",
|
963 |
+
" <td>NaN</td>\n",
|
964 |
+
" <td>NaN</td>\n",
|
965 |
+
" <td>NaN</td>\n",
|
966 |
+
" <td>NaN</td>\n",
|
967 |
+
" <td>NaN</td>\n",
|
968 |
+
" <td>NaN</td>\n",
|
969 |
+
" <td>NoHR</td>\n",
|
970 |
+
" <td>0.454722</td>\n",
|
971 |
+
" <td>NaN</td>\n",
|
972 |
+
" </tr>\n",
|
973 |
+
" <tr>\n",
|
974 |
+
" <th>4</th>\n",
|
975 |
+
" <td>8330224933</td>\n",
|
976 |
+
" <td>2023-01-01 06:53:06</td>\n",
|
977 |
+
" <td>午後のライド</td>\n",
|
978 |
+
" <td>ライド</td>\n",
|
979 |
+
" <td>NaN</td>\n",
|
980 |
+
" <td>1222</td>\n",
|
981 |
+
" <td>7.62</td>\n",
|
982 |
+
" <td>NaN</td>\n",
|
983 |
+
" <td>NaN</td>\n",
|
984 |
+
" <td>False</td>\n",
|
985 |
+
" <td>...</td>\n",
|
986 |
+
" <td>NaN</td>\n",
|
987 |
+
" <td>NaN</td>\n",
|
988 |
+
" <td>NaN</td>\n",
|
989 |
+
" <td>NaN</td>\n",
|
990 |
+
" <td>NaN</td>\n",
|
991 |
+
" <td>NaN</td>\n",
|
992 |
+
" <td>NaN</td>\n",
|
993 |
+
" <td>NoHR</td>\n",
|
994 |
+
" <td>0.325278</td>\n",
|
995 |
+
" <td>NaN</td>\n",
|
996 |
+
" </tr>\n",
|
997 |
+
" </tbody>\n",
|
998 |
+
"</table>\n",
|
999 |
+
"<p>5 rows × 98 columns</p>\n",
|
1000 |
+
"</div>"
|
1001 |
+
],
|
1002 |
+
"text/plain": [
|
1003 |
+
" Activity ID Activity Date Activity Name Activity Type Description \\\n",
|
1004 |
+
"0 8280988291 2022-12-23 06:57:23 午後のランニング ランニング NaN \n",
|
1005 |
+
"1 8286585787 2022-12-24 09:57:04 夕方の水泳 水泳 NaN \n",
|
1006 |
+
"2 8293206227 2022-12-26 10:42:37 夕方の水泳 水泳 NaN \n",
|
1007 |
+
"3 8314368113 2022-12-31 06:05:56 午後のライド ライド NaN \n",
|
1008 |
+
"4 8330224933 2023-01-01 06:53:06 午後のライド ライド NaN \n",
|
1009 |
+
"\n",
|
1010 |
+
" Elapsed Time Distance Max Heart Rate Relative Effort Commute ... \\\n",
|
1011 |
+
"0 1530 4.62 NaN NaN False ... \n",
|
1012 |
+
"1 4454 1150.00 NaN NaN False ... \n",
|
1013 |
+
"2 4556 550.00 NaN NaN False ... \n",
|
1014 |
+
"3 1897 9.10 NaN NaN False ... \n",
|
1015 |
+
"4 1222 7.62 NaN NaN False ... \n",
|
1016 |
+
"\n",
|
1017 |
+
" Training Load Intensity Grade Adjusted Pace (Average) Timer Time \\\n",
|
1018 |
+
"0 NaN NaN NaN NaN \n",
|
1019 |
+
"1 NaN NaN NaN NaN \n",
|
1020 |
+
"2 NaN NaN NaN NaN \n",
|
1021 |
+
"3 NaN NaN NaN NaN \n",
|
1022 |
+
"4 NaN NaN NaN NaN \n",
|
1023 |
+
"\n",
|
1024 |
+
" Total Cycles Media intensity_level training_category moving_hr trimp \n",
|
1025 |
+
"0 NaN NaN NaN NoHR 0.421944 NaN \n",
|
1026 |
+
"1 NaN NaN NaN NoHR 0.446111 NaN \n",
|
1027 |
+
"2 NaN NaN NaN NoHR 0.400278 NaN \n",
|
1028 |
+
"3 NaN NaN NaN NoHR 0.454722 NaN \n",
|
1029 |
+
"4 NaN NaN NaN NoHR 0.325278 NaN \n",
|
1030 |
+
"\n",
|
1031 |
+
"[5 rows x 98 columns]"
|
1032 |
+
]
|
1033 |
+
},
|
1034 |
+
"execution_count": 25,
|
1035 |
+
"metadata": {},
|
1036 |
+
"output_type": "execute_result"
|
1037 |
+
}
|
1038 |
+
],
|
1039 |
+
"source": [
|
1040 |
+
"test = pd.read_parquet(parq_path)\n",
|
1041 |
+
"print(test.shape, \"rows x columns\")\n",
|
1042 |
+
"test.head()\n"
|
1043 |
+
]
|
1044 |
+
},
|
1045 |
+
{
|
1046 |
+
"cell_type": "code",
|
1047 |
+
"execution_count": 26,
|
1048 |
+
"id": "98daa8dc",
|
1049 |
+
"metadata": {},
|
1050 |
+
"outputs": [],
|
1051 |
+
"source": [
|
1052 |
+
"root = Path(\"/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset\")\n",
|
1053 |
+
"df = pd.read_parquet(root / \"strava_master_enhanced.parquet\")"
|
1054 |
+
]
|
1055 |
+
},
|
1056 |
+
{
|
1057 |
+
"cell_type": "code",
|
1058 |
+
"execution_count": 27,
|
1059 |
+
"id": "8ec21e06",
|
1060 |
+
"metadata": {},
|
1061 |
+
"outputs": [
|
1062 |
+
{
|
1063 |
+
"ename": "KeyError",
|
1064 |
+
"evalue": "'date'",
|
1065 |
+
"output_type": "error",
|
1066 |
+
"traceback": [
|
1067 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
1068 |
+
"\u001b[31mKeyError\u001b[39m Traceback (most recent call last)",
|
1069 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/indexes/base.py:3805\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m 3804\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m3805\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_engine\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 3806\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
|
1070 |
+
"\u001b[36mFile \u001b[39m\u001b[32mindex.pyx:167\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
|
1071 |
+
"\u001b[36mFile \u001b[39m\u001b[32mindex.pyx:196\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
|
1072 |
+
"\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/hashtable_class_helper.pxi:7081\u001b[39m, in \u001b[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[39m\u001b[34m()\u001b[39m\n",
|
1073 |
+
"\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/hashtable_class_helper.pxi:7089\u001b[39m, in \u001b[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[39m\u001b[34m()\u001b[39m\n",
|
1074 |
+
"\u001b[31mKeyError\u001b[39m: 'date'",
|
1075 |
+
"\nThe above exception was the direct cause of the following exception:\n",
|
1076 |
+
"\u001b[31mKeyError\u001b[39m Traceback (most recent call last)",
|
1077 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[27]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m df[\u001b[33m\"\u001b[39m\u001b[33myear\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[43mdf\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mdate\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m.dt.year\n\u001b[32m 2\u001b[39m df[\u001b[33m\"\u001b[39m\u001b[33mweek\u001b[39m\u001b[33m\"\u001b[39m] = df[\u001b[33m\"\u001b[39m\u001b[33mdate\u001b[39m\u001b[33m\"\u001b[39m].dt.isocalendar().week\n\u001b[32m 3\u001b[39m df[\u001b[33m\"\u001b[39m\u001b[33mmonth\u001b[39m\u001b[33m\"\u001b[39m] = df[\u001b[33m\"\u001b[39m\u001b[33mdate\u001b[39m\u001b[33m\"\u001b[39m].dt.month\n",
|
1078 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/frame.py:4102\u001b[39m, in \u001b[36mDataFrame.__getitem__\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m 4100\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.columns.nlevels > \u001b[32m1\u001b[39m:\n\u001b[32m 4101\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._getitem_multilevel(key)\n\u001b[32m-> \u001b[39m\u001b[32m4102\u001b[39m indexer = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mcolumns\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 4103\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[32m 4104\u001b[39m indexer = [indexer]\n",
|
1079 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/indexes/base.py:3812\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m 3807\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(casted_key, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[32m 3808\u001b[39m \u001b[38;5;28misinstance\u001b[39m(casted_key, abc.Iterable)\n\u001b[32m 3809\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28many\u001b[39m(\u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m casted_key)\n\u001b[32m 3810\u001b[39m ):\n\u001b[32m 3811\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m InvalidIndexError(key)\n\u001b[32m-> \u001b[39m\u001b[32m3812\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[34;01merr\u001b[39;00m\n\u001b[32m 3813\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[32m 3814\u001b[39m \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[32m 3815\u001b[39m \u001b[38;5;66;03m# InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[32m 3816\u001b[39m \u001b[38;5;66;03m# the TypeError.\u001b[39;00m\n\u001b[32m 3817\u001b[39m \u001b[38;5;28mself\u001b[39m._check_indexing_error(key)\n",
|
1080 |
+
"\u001b[31mKeyError\u001b[39m: 'date'"
|
1081 |
+
]
|
1082 |
+
}
|
1083 |
+
],
|
1084 |
+
"source": [
|
1085 |
+
"df[\"year\"] = df[\"date\"].dt.year\n",
|
1086 |
+
"df[\"week\"] = df[\"date\"].dt.isocalendar().week\n",
|
1087 |
+
"df[\"month\"] = df[\"date\"].dt.month"
|
1088 |
+
]
|
1089 |
+
},
|
1090 |
+
{
|
1091 |
+
"cell_type": "code",
|
1092 |
+
"execution_count": 28,
|
1093 |
+
"id": "0c80a049",
|
1094 |
+
"metadata": {},
|
1095 |
+
"outputs": [
|
1096 |
+
{
|
1097 |
+
"name": "stdout",
|
1098 |
+
"output_type": "stream",
|
1099 |
+
"text": [
|
1100 |
+
"['Activity ID', 'Activity Date', 'Activity Name', 'Activity Type', 'Description', 'Elapsed Time', 'Distance', 'Max Heart Rate', 'Relative Effort', 'Commute', 'Activity Private Notes', 'Gear', 'Filename', 'Athlete Weight', 'Bike Weight']\n"
|
1101 |
+
]
|
1102 |
+
}
|
1103 |
+
],
|
1104 |
+
"source": [
|
1105 |
+
"print(df.columns.tolist()[:15]) # 列名をざっと表示\n"
|
1106 |
+
]
|
1107 |
+
},
|
1108 |
+
{
|
1109 |
+
"cell_type": "code",
|
1110 |
+
"execution_count": 29,
|
1111 |
+
"id": "3fcb9c20",
|
1112 |
+
"metadata": {},
|
1113 |
+
"outputs": [],
|
1114 |
+
"source": [
|
1115 |
+
"df = df.rename(columns={\"Activity Date\": \"date\"}) # 列名が違えば適宜変更\n",
|
1116 |
+
"df[\"date\"] = pd.to_datetime(df[\"date\"]) # 念のため datetime 型へ\n"
|
1117 |
+
]
|
1118 |
+
},
|
1119 |
+
{
|
1120 |
+
"cell_type": "code",
|
1121 |
+
"execution_count": 30,
|
1122 |
+
"id": "78880905",
|
1123 |
+
"metadata": {},
|
1124 |
+
"outputs": [],
|
1125 |
+
"source": [
|
1126 |
+
"df[\"year\"] = df[\"date\"].dt.year\n",
|
1127 |
+
"df[\"week\"] = df[\"date\"].dt.isocalendar().week\n",
|
1128 |
+
"df[\"month\"] = df[\"date\"].dt.month"
|
1129 |
+
]
|
1130 |
+
},
|
1131 |
+
{
|
1132 |
+
"cell_type": "code",
|
1133 |
+
"execution_count": 31,
|
1134 |
+
"id": "51c2d9f2",
|
1135 |
+
"metadata": {},
|
1136 |
+
"outputs": [
|
1137 |
+
{
|
1138 |
+
"ename": "KeyError",
|
1139 |
+
"evalue": "\"Column(s) ['distance_km'] do not exist\"",
|
1140 |
+
"output_type": "error",
|
1141 |
+
"traceback": [
|
1142 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
1143 |
+
"\u001b[31mKeyError\u001b[39m Traceback (most recent call last)",
|
1144 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[31]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m weekly_sport = (\n\u001b[32m 2\u001b[39m \u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mgroupby\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43myear\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mweek\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mActivity Type\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mas_index\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[43m \u001b[49m\u001b[43m.\u001b[49m\u001b[43magg\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtotal_dur_hr\u001b[49m\u001b[43m=\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmoving_hr\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43msum\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 4\u001b[39m \u001b[43m \u001b[49m\u001b[43mdist_km\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mdistance_km\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43msum\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 5\u001b[39m \u001b[43m \u001b[49m\u001b[43mtrimp_sum\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtrimp\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43msum\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 6\u001b[39m )\n",
|
1145 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/groupby/generic.py:1432\u001b[39m, in \u001b[36mDataFrameGroupBy.aggregate\u001b[39m\u001b[34m(self, func, engine, engine_kwargs, *args, **kwargs)\u001b[39m\n\u001b[32m 1429\u001b[39m kwargs[\u001b[33m\"\u001b[39m\u001b[33mengine_kwargs\u001b[39m\u001b[33m\"\u001b[39m] = engine_kwargs\n\u001b[32m 1431\u001b[39m op = GroupByApply(\u001b[38;5;28mself\u001b[39m, func, args=args, kwargs=kwargs)\n\u001b[32m-> \u001b[39m\u001b[32m1432\u001b[39m result = \u001b[43mop\u001b[49m\u001b[43m.\u001b[49m\u001b[43magg\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1433\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m is_dict_like(func) \u001b[38;5;129;01mand\u001b[39;00m result \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m 1434\u001b[39m \u001b[38;5;66;03m# GH #52849\u001b[39;00m\n\u001b[32m 1435\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m.as_index \u001b[38;5;129;01mand\u001b[39;00m is_list_like(func):\n",
|
1146 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/apply.py:190\u001b[39m, in \u001b[36mApply.agg\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 187\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m.apply_str()\n\u001b[32m 189\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m is_dict_like(func):\n\u001b[32m--> \u001b[39m\u001b[32m190\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43magg_dict_like\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 191\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m is_list_like(func):\n\u001b[32m 192\u001b[39m \u001b[38;5;66;03m# we require a list, but not a 'str'\u001b[39;00m\n\u001b[32m 193\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m.agg_list_like()\n",
|
1147 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/apply.py:423\u001b[39m, in \u001b[36mApply.agg_dict_like\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 415\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[34magg_dict_like\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> DataFrame | Series:\n\u001b[32m 416\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 417\u001b[39m \u001b[33;03m Compute aggregation in the case of a dict-like argument.\u001b[39;00m\n\u001b[32m 418\u001b[39m \n\u001b[32m (...)\u001b[39m\u001b[32m 421\u001b[39m \u001b[33;03m Result of aggregation.\u001b[39;00m\n\u001b[32m 422\u001b[39m \u001b[33;03m \"\"\"\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m423\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43magg_or_apply_dict_like\u001b[49m\u001b[43m(\u001b[49m\u001b[43mop_name\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43magg\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
1148 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/apply.py:1608\u001b[39m, in \u001b[36mGroupByApply.agg_or_apply_dict_like\u001b[39m\u001b[34m(self, op_name)\u001b[39m\n\u001b[32m 1603\u001b[39m kwargs.update({\u001b[33m\"\u001b[39m\u001b[33mengine\u001b[39m\u001b[33m\"\u001b[39m: engine, \u001b[33m\"\u001b[39m\u001b[33mengine_kwargs\u001b[39m\u001b[33m\"\u001b[39m: engine_kwargs})\n\u001b[32m 1605\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m com.temp_setattr(\n\u001b[32m 1606\u001b[39m obj, \u001b[33m\"\u001b[39m\u001b[33mas_index\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mTrue\u001b[39;00m, condition=\u001b[38;5;28mhasattr\u001b[39m(obj, \u001b[33m\"\u001b[39m\u001b[33mas_index\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 1607\u001b[39m ):\n\u001b[32m-> \u001b[39m\u001b[32m1608\u001b[39m result_index, result_data = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mcompute_dict_like\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1609\u001b[39m \u001b[43m \u001b[49m\u001b[43mop_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mselected_obj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mselection\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\n\u001b[32m 1610\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1611\u001b[39m result = \u001b[38;5;28mself\u001b[39m.wrap_results_dict_like(selected_obj, result_index, result_data)\n\u001b[32m 1612\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
|
1149 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/apply.py:462\u001b[39m, in \u001b[36mApply.compute_dict_like\u001b[39m\u001b[34m(self, op_name, selected_obj, selection, kwargs)\u001b[39m\n\u001b[32m 460\u001b[39m is_groupby = \u001b[38;5;28misinstance\u001b[39m(obj, (DataFrameGroupBy, SeriesGroupBy))\n\u001b[32m 461\u001b[39m func = cast(AggFuncTypeDict, \u001b[38;5;28mself\u001b[39m.func)\n\u001b[32m--> \u001b[39m\u001b[32m462\u001b[39m func = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mnormalize_dictlike_arg\u001b[49m\u001b[43m(\u001b[49m\u001b[43mop_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mselected_obj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 464\u001b[39m is_non_unique_col = (\n\u001b[32m 465\u001b[39m selected_obj.ndim == \u001b[32m2\u001b[39m\n\u001b[32m 466\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m selected_obj.columns.nunique() < \u001b[38;5;28mlen\u001b[39m(selected_obj.columns)\n\u001b[32m 467\u001b[39m )\n\u001b[32m 469\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m selected_obj.ndim == \u001b[32m1\u001b[39m:\n\u001b[32m 470\u001b[39m \u001b[38;5;66;03m# key only used for output\u001b[39;00m\n",
|
1150 |
+
"\u001b[36mFile \u001b[39m\u001b[32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/pandas/core/apply.py:663\u001b[39m, in \u001b[36mApply.normalize_dictlike_arg\u001b[39m\u001b[34m(self, how, obj, func)\u001b[39m\n\u001b[32m 661\u001b[39m cols = Index(\u001b[38;5;28mlist\u001b[39m(func.keys())).difference(obj.columns, sort=\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[32m 662\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(cols) > \u001b[32m0\u001b[39m:\n\u001b[32m--> \u001b[39m\u001b[32m663\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mColumn(s) \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlist\u001b[39m(cols)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m do not exist\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 665\u001b[39m aggregator_types = (\u001b[38;5;28mlist\u001b[39m, \u001b[38;5;28mtuple\u001b[39m, \u001b[38;5;28mdict\u001b[39m)\n\u001b[32m 667\u001b[39m \u001b[38;5;66;03m# if we have a dict of any non-scalars\u001b[39;00m\n\u001b[32m 668\u001b[39m \u001b[38;5;66;03m# eg. {'A' : ['mean']}, normalize all to\u001b[39;00m\n\u001b[32m 669\u001b[39m \u001b[38;5;66;03m# be list-likes\u001b[39;00m\n\u001b[32m 670\u001b[39m \u001b[38;5;66;03m# Cannot use func.values() because arg may be a Series\u001b[39;00m\n",
|
1151 |
+
"\u001b[31mKeyError\u001b[39m: \"Column(s) ['distance_km'] do not exist\""
|
1152 |
+
]
|
1153 |
+
}
|
1154 |
+
],
|
1155 |
+
"source": [
|
1156 |
+
"weekly_sport = (\n",
|
1157 |
+
" df.groupby([\"year\", \"week\", \"Activity Type\"], as_index=False)\n",
|
1158 |
+
" .agg(total_dur_hr=(\"moving_hr\", \"sum\"),\n",
|
1159 |
+
" dist_km =(\"distance_km\", \"sum\"),\n",
|
1160 |
+
" trimp_sum =(\"trimp\", \"sum\"))\n",
|
1161 |
+
")\n"
|
1162 |
+
]
|
1163 |
+
},
|
1164 |
+
{
|
1165 |
+
"cell_type": "code",
|
1166 |
+
"execution_count": 32,
|
1167 |
+
"id": "12b131a0",
|
1168 |
+
"metadata": {},
|
1169 |
+
"outputs": [
|
1170 |
+
{
|
1171 |
+
"name": "stdout",
|
1172 |
+
"output_type": "stream",
|
1173 |
+
"text": [
|
1174 |
+
"['Distance', 'Distance.1', 'Dirt Distance', 'Newly Explored Distance', 'Newly Explored Dirt Distance']\n"
|
1175 |
+
]
|
1176 |
+
}
|
1177 |
+
],
|
1178 |
+
"source": [
|
1179 |
+
"print([c for c in df.columns if \"Distance\" in c])"
|
1180 |
+
]
|
1181 |
+
},
|
1182 |
+
{
|
1183 |
+
"cell_type": "code",
|
1184 |
+
"execution_count": 33,
|
1185 |
+
"id": "2b509864",
|
1186 |
+
"metadata": {},
|
1187 |
+
"outputs": [],
|
1188 |
+
"source": [
|
1189 |
+
"if \"Distance\" in df.columns:\n",
|
1190 |
+
" df[\"distance_km\"] = pd.to_numeric(df[\"Distance\"], errors=\"coerce\") / 1000\n",
|
1191 |
+
"else:\n",
|
1192 |
+
" raise KeyError(\"Distance 列が見つかりません。列名を確認してください。\")"
|
1193 |
+
]
|
1194 |
+
},
|
1195 |
+
{
|
1196 |
+
"cell_type": "code",
|
1197 |
+
"execution_count": 34,
|
1198 |
+
"id": "bc930eeb",
|
1199 |
+
"metadata": {},
|
1200 |
+
"outputs": [
|
1201 |
+
{
|
1202 |
+
"data": {
|
1203 |
+
"text/html": [
|
1204 |
+
"<div>\n",
|
1205 |
+
"<style scoped>\n",
|
1206 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1207 |
+
" vertical-align: middle;\n",
|
1208 |
+
" }\n",
|
1209 |
+
"\n",
|
1210 |
+
" .dataframe tbody tr th {\n",
|
1211 |
+
" vertical-align: top;\n",
|
1212 |
+
" }\n",
|
1213 |
+
"\n",
|
1214 |
+
" .dataframe thead th {\n",
|
1215 |
+
" text-align: right;\n",
|
1216 |
+
" }\n",
|
1217 |
+
"</style>\n",
|
1218 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1219 |
+
" <thead>\n",
|
1220 |
+
" <tr style=\"text-align: right;\">\n",
|
1221 |
+
" <th></th>\n",
|
1222 |
+
" <th>year</th>\n",
|
1223 |
+
" <th>week</th>\n",
|
1224 |
+
" <th>Activity Type</th>\n",
|
1225 |
+
" <th>total_dur_hr</th>\n",
|
1226 |
+
" <th>dist_km</th>\n",
|
1227 |
+
" <th>trimp_sum</th>\n",
|
1228 |
+
" </tr>\n",
|
1229 |
+
" </thead>\n",
|
1230 |
+
" <tbody>\n",
|
1231 |
+
" <tr>\n",
|
1232 |
+
" <th>0</th>\n",
|
1233 |
+
" <td>2022</td>\n",
|
1234 |
+
" <td>51</td>\n",
|
1235 |
+
" <td>ランニング</td>\n",
|
1236 |
+
" <td>0.421944</td>\n",
|
1237 |
+
" <td>0.00462</td>\n",
|
1238 |
+
" <td>0.0</td>\n",
|
1239 |
+
" </tr>\n",
|
1240 |
+
" <tr>\n",
|
1241 |
+
" <th>1</th>\n",
|
1242 |
+
" <td>2022</td>\n",
|
1243 |
+
" <td>51</td>\n",
|
1244 |
+
" <td>水泳</td>\n",
|
1245 |
+
" <td>0.446111</td>\n",
|
1246 |
+
" <td>1.15000</td>\n",
|
1247 |
+
" <td>0.0</td>\n",
|
1248 |
+
" </tr>\n",
|
1249 |
+
" <tr>\n",
|
1250 |
+
" <th>2</th>\n",
|
1251 |
+
" <td>2022</td>\n",
|
1252 |
+
" <td>52</td>\n",
|
1253 |
+
" <td>ライド</td>\n",
|
1254 |
+
" <td>0.454722</td>\n",
|
1255 |
+
" <td>0.00910</td>\n",
|
1256 |
+
" <td>0.0</td>\n",
|
1257 |
+
" </tr>\n",
|
1258 |
+
" <tr>\n",
|
1259 |
+
" <th>3</th>\n",
|
1260 |
+
" <td>2022</td>\n",
|
1261 |
+
" <td>52</td>\n",
|
1262 |
+
" <td>水泳</td>\n",
|
1263 |
+
" <td>0.400278</td>\n",
|
1264 |
+
" <td>0.55000</td>\n",
|
1265 |
+
" <td>0.0</td>\n",
|
1266 |
+
" </tr>\n",
|
1267 |
+
" <tr>\n",
|
1268 |
+
" <th>4</th>\n",
|
1269 |
+
" <td>2023</td>\n",
|
1270 |
+
" <td>1</td>\n",
|
1271 |
+
" <td>ウェイトトレーニング</td>\n",
|
1272 |
+
" <td>1.250278</td>\n",
|
1273 |
+
" <td>0.00000</td>\n",
|
1274 |
+
" <td>0.0</td>\n",
|
1275 |
+
" </tr>\n",
|
1276 |
+
" </tbody>\n",
|
1277 |
+
"</table>\n",
|
1278 |
+
"</div>"
|
1279 |
+
],
|
1280 |
+
"text/plain": [
|
1281 |
+
" year week Activity Type total_dur_hr dist_km trimp_sum\n",
|
1282 |
+
"0 2022 51 ランニング 0.421944 0.00462 0.0\n",
|
1283 |
+
"1 2022 51 水泳 0.446111 1.15000 0.0\n",
|
1284 |
+
"2 2022 52 ライド 0.454722 0.00910 0.0\n",
|
1285 |
+
"3 2022 52 水泳 0.400278 0.55000 0.0\n",
|
1286 |
+
"4 2023 1 ウェイトトレーニング 1.250278 0.00000 0.0"
|
1287 |
+
]
|
1288 |
+
},
|
1289 |
+
"execution_count": 34,
|
1290 |
+
"metadata": {},
|
1291 |
+
"output_type": "execute_result"
|
1292 |
+
}
|
1293 |
+
],
|
1294 |
+
"source": [
|
1295 |
+
"weekly_sport = (\n",
|
1296 |
+
" df.groupby([\"year\", \"week\", \"Activity Type\"], as_index=False)\n",
|
1297 |
+
" .agg(total_dur_hr=(\"moving_hr\", \"sum\"),\n",
|
1298 |
+
" dist_km =(\"distance_km\", \"sum\"),\n",
|
1299 |
+
" trimp_sum =(\"trimp\", \"sum\"))\n",
|
1300 |
+
")\n",
|
1301 |
+
"weekly_sport.head()"
|
1302 |
+
]
|
1303 |
+
},
|
1304 |
+
{
|
1305 |
+
"cell_type": "code",
|
1306 |
+
"execution_count": 1,
|
1307 |
+
"id": "29556526",
|
1308 |
+
"metadata": {},
|
1309 |
+
"outputs": [
|
1310 |
+
{
|
1311 |
+
"ename": "NameError",
|
1312 |
+
"evalue": "name 'df' is not defined",
|
1313 |
+
"output_type": "error",
|
1314 |
+
"traceback": [
|
1315 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
1316 |
+
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
|
1317 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[43mdf\u001b[49m.shape)\n",
|
1318 |
+
"\u001b[31mNameError\u001b[39m: name 'df' is not defined"
|
1319 |
+
]
|
1320 |
+
}
|
1321 |
+
],
|
1322 |
+
"source": [
|
1323 |
+
"print(df.shape)"
|
1324 |
+
]
|
1325 |
+
},
|
1326 |
+
{
|
1327 |
+
"cell_type": "code",
|
1328 |
+
"execution_count": 2,
|
1329 |
+
"id": "456de871",
|
1330 |
+
"metadata": {},
|
1331 |
+
"outputs": [
|
1332 |
+
{
|
1333 |
+
"ename": "NameError",
|
1334 |
+
"evalue": "name 'pd' is not defined",
|
1335 |
+
"output_type": "error",
|
1336 |
+
"traceback": [
|
1337 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
1338 |
+
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
|
1339 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m df = \u001b[43mpd\u001b[49m.read_parquet(\u001b[33m\"\u001b[39m\u001b[33m/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset/strava_master_enhanced.parquet\u001b[39m\u001b[33m\"\u001b[39m)\n",
|
1340 |
+
"\u001b[31mNameError\u001b[39m: name 'pd' is not defined"
|
1341 |
+
]
|
1342 |
+
}
|
1343 |
+
],
|
1344 |
+
"source": [
|
1345 |
+
"df = pd.read_parquet(\"/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset/strava_master_enhanced.parquet\")"
|
1346 |
+
]
|
1347 |
+
},
|
1348 |
+
{
|
1349 |
+
"cell_type": "code",
|
1350 |
+
"execution_count": 3,
|
1351 |
+
"id": "5119551a",
|
1352 |
+
"metadata": {},
|
1353 |
+
"outputs": [
|
1354 |
+
{
|
1355 |
+
"ename": "ModuleNotFoundError",
|
1356 |
+
"evalue": "No module named 'matplotlib'",
|
1357 |
+
"output_type": "error",
|
1358 |
+
"traceback": [
|
1359 |
+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
1360 |
+
"\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)",
|
1361 |
+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[34;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[34;01mpd\u001b[39;00m\n\u001b[32m 2\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[34;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[34;01mnp\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[34;01mmatplotlib\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mpyplot\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[34;01mplt\u001b[39;00m \u001b[38;5;66;03m# 軽い可視化用\u001b[39;00m\n",
|
1362 |
+
"\u001b[31mModuleNotFoundError\u001b[39m: No module named 'matplotlib'"
|
1363 |
+
]
|
1364 |
+
}
|
1365 |
+
],
|
1366 |
+
"source": [
|
1367 |
+
"import pandas as pd\n",
|
1368 |
+
"import numpy as np\n",
|
1369 |
+
"import matplotlib.pyplot as plt # 軽い可視化用\n",
|
1370 |
+
"\n"
|
1371 |
+
]
|
1372 |
+
},
|
1373 |
+
{
|
1374 |
+
"cell_type": "code",
|
1375 |
+
"execution_count": 4,
|
1376 |
+
"id": "0c049c2c",
|
1377 |
+
"metadata": {},
|
1378 |
+
"outputs": [],
|
1379 |
+
"source": [
|
1380 |
+
"import pandas as pd\n",
|
1381 |
+
"import numpy as np"
|
1382 |
+
]
|
1383 |
+
},
|
1384 |
+
{
|
1385 |
+
"cell_type": "code",
|
1386 |
+
"execution_count": 6,
|
1387 |
+
"id": "4bdfd9b8",
|
1388 |
+
"metadata": {},
|
1389 |
+
"outputs": [],
|
1390 |
+
"source": [
|
1391 |
+
"df = pd.read_parquet(\"/Users/jitsugen/Documents/SoloPRJ/Strava-Dataset-PRJ/my_strava_dataset/strava_master_enhanced.parquet\")\n"
|
1392 |
+
]
|
1393 |
+
},
|
1394 |
+
{
|
1395 |
+
"cell_type": "code",
|
1396 |
+
"execution_count": 7,
|
1397 |
+
"id": "7fe05117",
|
1398 |
+
"metadata": {},
|
1399 |
+
"outputs": [
|
1400 |
+
{
|
1401 |
+
"name": "stdout",
|
1402 |
+
"output_type": "stream",
|
1403 |
+
"text": [
|
1404 |
+
"(474, 98)\n"
|
1405 |
+
]
|
1406 |
+
}
|
1407 |
+
],
|
1408 |
+
"source": [
|
1409 |
+
"print(df.shape)"
|
1410 |
+
]
|
1411 |
+
},
|
1412 |
+
{
|
1413 |
+
"cell_type": "code",
|
1414 |
+
"execution_count": 8,
|
1415 |
+
"id": "29cfcdc4",
|
1416 |
+
"metadata": {},
|
1417 |
+
"outputs": [
|
1418 |
+
{
|
1419 |
+
"name": "stdout",
|
1420 |
+
"output_type": "stream",
|
1421 |
+
"text": [
|
1422 |
+
"['Activity ID', 'Activity Date', 'Activity Name', 'Activity Type', 'Description', 'Elapsed Time', 'Distance', 'Max Heart Rate', 'Relative Effort', 'Commute', 'Activity Private Notes', 'Gear', 'Filename', 'Athlete Weight', 'Bike Weight', 'Elapsed Time.1', 'Moving Time', 'Distance.1', 'Max Speed', 'Average Speed', 'Elevation Gain', 'Elevation Loss', 'Min Elevation', 'Max Elevation', 'Max Grade', 'Average Grade', 'Average Positive Grade', 'Average Negative Grade', 'Max Cadence', 'Average Cadence', 'Max Heart Rate.1', 'Average Heart Rate', 'Max Power', 'Average Power', 'Calories', 'Max Temperature', 'Average Temperature', 'Relative Effort.1', 'Total Work', 'Number of Runs', 'Uphill Time', 'Downhill Time', 'Other Time', 'Perceived Exertion', 'Device Type', 'Start Time', 'Weighted Average Power', 'Power Count', 'Perceived Exertion Used', 'Perceived Relative Effort', 'Commute.1', 'Total Weight', 'Weather Observed', 'Grade Adjusted Pace', 'Observation Time', 'Weather', 'Average Temperature.1', 'Apparent Temperature', 'Dew Point', 'Humidity', 'Pressure', 'Wind Speed', 'Wind Gust', 'Wind Bearing', 'Precipitation', 'Sunset Time', 'Sunrise Time', 'Moon Phase', '自転車', 'Gear.1', 'Precipitation Probability', 'Precipitation Type', 'Cloud Cover', 'Visibility', 'UV Index', 'Ozone', 'Jump Count', 'Total Grit', 'Average Flow', 'Flagged', 'Average Elapsed Speed', 'Dirt Distance', 'Newly Explored Distance', 'Newly Explored Dirt Distance', 'Activity Count', 'Step Count', 'Carbon Savings', 'Pool Length', 'Training Load', 'Intensity', 'Grade Adjusted Pace (Average)', 'Timer Time', 'Total Cycles', 'Media', 'intensity_level', 'training_category', 'moving_hr', 'trimp']\n"
|
1423 |
+
]
|
1424 |
+
}
|
1425 |
+
],
|
1426 |
+
"source": [
|
1427 |
+
"print(df.columns.tolist())"
|
1428 |
+
]
|
1429 |
+
},
|
1430 |
+
{
|
1431 |
+
"cell_type": "code",
|
1432 |
+
"execution_count": 9,
|
1433 |
+
"id": "b3e75671",
|
1434 |
+
"metadata": {},
|
1435 |
+
"outputs": [
|
1436 |
+
{
|
1437 |
+
"data": {
|
1438 |
+
"text/html": [
|
1439 |
+
"<div>\n",
|
1440 |
+
"<style scoped>\n",
|
1441 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1442 |
+
" vertical-align: middle;\n",
|
1443 |
+
" }\n",
|
1444 |
+
"\n",
|
1445 |
+
" .dataframe tbody tr th {\n",
|
1446 |
+
" vertical-align: top;\n",
|
1447 |
+
" }\n",
|
1448 |
+
"\n",
|
1449 |
+
" .dataframe thead th {\n",
|
1450 |
+
" text-align: right;\n",
|
1451 |
+
" }\n",
|
1452 |
+
"</style>\n",
|
1453 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1454 |
+
" <thead>\n",
|
1455 |
+
" <tr style=\"text-align: right;\">\n",
|
1456 |
+
" <th></th>\n",
|
1457 |
+
" <th>Activity ID</th>\n",
|
1458 |
+
" <th>Activity Date</th>\n",
|
1459 |
+
" <th>Activity Name</th>\n",
|
1460 |
+
" <th>Activity Type</th>\n",
|
1461 |
+
" <th>Description</th>\n",
|
1462 |
+
" <th>Elapsed Time</th>\n",
|
1463 |
+
" <th>Distance</th>\n",
|
1464 |
+
" <th>Max Heart Rate</th>\n",
|
1465 |
+
" <th>Relative Effort</th>\n",
|
1466 |
+
" <th>Commute</th>\n",
|
1467 |
+
" <th>...</th>\n",
|
1468 |
+
" <th>Training Load</th>\n",
|
1469 |
+
" <th>Intensity</th>\n",
|
1470 |
+
" <th>Grade Adjusted Pace (Average)</th>\n",
|
1471 |
+
" <th>Timer Time</th>\n",
|
1472 |
+
" <th>Total Cycles</th>\n",
|
1473 |
+
" <th>Media</th>\n",
|
1474 |
+
" <th>intensity_level</th>\n",
|
1475 |
+
" <th>training_category</th>\n",
|
1476 |
+
" <th>moving_hr</th>\n",
|
1477 |
+
" <th>trimp</th>\n",
|
1478 |
+
" </tr>\n",
|
1479 |
+
" </thead>\n",
|
1480 |
+
" <tbody>\n",
|
1481 |
+
" <tr>\n",
|
1482 |
+
" <th>0</th>\n",
|
1483 |
+
" <td>8280988291</td>\n",
|
1484 |
+
" <td>2022-12-23 06:57:23</td>\n",
|
1485 |
+
" <td>午後のランニング</td>\n",
|
1486 |
+
" <td>ランニング</td>\n",
|
1487 |
+
" <td>NaN</td>\n",
|
1488 |
+
" <td>1530</td>\n",
|
1489 |
+
" <td>4.62</td>\n",
|
1490 |
+
" <td>NaN</td>\n",
|
1491 |
+
" <td>NaN</td>\n",
|
1492 |
+
" <td>False</td>\n",
|
1493 |
+
" <td>...</td>\n",
|
1494 |
+
" <td>NaN</td>\n",
|
1495 |
+
" <td>NaN</td>\n",
|
1496 |
+
" <td>NaN</td>\n",
|
1497 |
+
" <td>NaN</td>\n",
|
1498 |
+
" <td>NaN</td>\n",
|
1499 |
+
" <td>NaN</td>\n",
|
1500 |
+
" <td>NaN</td>\n",
|
1501 |
+
" <td>NoHR</td>\n",
|
1502 |
+
" <td>0.421944</td>\n",
|
1503 |
+
" <td>NaN</td>\n",
|
1504 |
+
" </tr>\n",
|
1505 |
+
" <tr>\n",
|
1506 |
+
" <th>1</th>\n",
|
1507 |
+
" <td>8286585787</td>\n",
|
1508 |
+
" <td>2022-12-24 09:57:04</td>\n",
|
1509 |
+
" <td>夕方の水泳</td>\n",
|
1510 |
+
" <td>水泳</td>\n",
|
1511 |
+
" <td>NaN</td>\n",
|
1512 |
+
" <td>4454</td>\n",
|
1513 |
+
" <td>1150.00</td>\n",
|
1514 |
+
" <td>NaN</td>\n",
|
1515 |
+
" <td>NaN</td>\n",
|
1516 |
+
" <td>False</td>\n",
|
1517 |
+
" <td>...</td>\n",
|
1518 |
+
" <td>NaN</td>\n",
|
1519 |
+
" <td>NaN</td>\n",
|
1520 |
+
" <td>NaN</td>\n",
|
1521 |
+
" <td>NaN</td>\n",
|
1522 |
+
" <td>NaN</td>\n",
|
1523 |
+
" <td>NaN</td>\n",
|
1524 |
+
" <td>NaN</td>\n",
|
1525 |
+
" <td>NoHR</td>\n",
|
1526 |
+
" <td>0.446111</td>\n",
|
1527 |
+
" <td>NaN</td>\n",
|
1528 |
+
" </tr>\n",
|
1529 |
+
" <tr>\n",
|
1530 |
+
" <th>2</th>\n",
|
1531 |
+
" <td>8293206227</td>\n",
|
1532 |
+
" <td>2022-12-26 10:42:37</td>\n",
|
1533 |
+
" <td>夕方の水泳</td>\n",
|
1534 |
+
" <td>水泳</td>\n",
|
1535 |
+
" <td>NaN</td>\n",
|
1536 |
+
" <td>4556</td>\n",
|
1537 |
+
" <td>550.00</td>\n",
|
1538 |
+
" <td>NaN</td>\n",
|
1539 |
+
" <td>NaN</td>\n",
|
1540 |
+
" <td>False</td>\n",
|
1541 |
+
" <td>...</td>\n",
|
1542 |
+
" <td>NaN</td>\n",
|
1543 |
+
" <td>NaN</td>\n",
|
1544 |
+
" <td>NaN</td>\n",
|
1545 |
+
" <td>NaN</td>\n",
|
1546 |
+
" <td>NaN</td>\n",
|
1547 |
+
" <td>NaN</td>\n",
|
1548 |
+
" <td>NaN</td>\n",
|
1549 |
+
" <td>NoHR</td>\n",
|
1550 |
+
" <td>0.400278</td>\n",
|
1551 |
+
" <td>NaN</td>\n",
|
1552 |
+
" </tr>\n",
|
1553 |
+
" <tr>\n",
|
1554 |
+
" <th>3</th>\n",
|
1555 |
+
" <td>8314368113</td>\n",
|
1556 |
+
" <td>2022-12-31 06:05:56</td>\n",
|
1557 |
+
" <td>午後のライド</td>\n",
|
1558 |
+
" <td>ライド</td>\n",
|
1559 |
+
" <td>NaN</td>\n",
|
1560 |
+
" <td>1897</td>\n",
|
1561 |
+
" <td>9.10</td>\n",
|
1562 |
+
" <td>NaN</td>\n",
|
1563 |
+
" <td>NaN</td>\n",
|
1564 |
+
" <td>False</td>\n",
|
1565 |
+
" <td>...</td>\n",
|
1566 |
+
" <td>NaN</td>\n",
|
1567 |
+
" <td>NaN</td>\n",
|
1568 |
+
" <td>NaN</td>\n",
|
1569 |
+
" <td>NaN</td>\n",
|
1570 |
+
" <td>NaN</td>\n",
|
1571 |
+
" <td>NaN</td>\n",
|
1572 |
+
" <td>NaN</td>\n",
|
1573 |
+
" <td>NoHR</td>\n",
|
1574 |
+
" <td>0.454722</td>\n",
|
1575 |
+
" <td>NaN</td>\n",
|
1576 |
+
" </tr>\n",
|
1577 |
+
" <tr>\n",
|
1578 |
+
" <th>4</th>\n",
|
1579 |
+
" <td>8330224933</td>\n",
|
1580 |
+
" <td>2023-01-01 06:53:06</td>\n",
|
1581 |
+
" <td>午後のライド</td>\n",
|
1582 |
+
" <td>ライド</td>\n",
|
1583 |
+
" <td>NaN</td>\n",
|
1584 |
+
" <td>1222</td>\n",
|
1585 |
+
" <td>7.62</td>\n",
|
1586 |
+
" <td>NaN</td>\n",
|
1587 |
+
" <td>NaN</td>\n",
|
1588 |
+
" <td>False</td>\n",
|
1589 |
+
" <td>...</td>\n",
|
1590 |
+
" <td>NaN</td>\n",
|
1591 |
+
" <td>NaN</td>\n",
|
1592 |
+
" <td>NaN</td>\n",
|
1593 |
+
" <td>NaN</td>\n",
|
1594 |
+
" <td>NaN</td>\n",
|
1595 |
+
" <td>NaN</td>\n",
|
1596 |
+
" <td>NaN</td>\n",
|
1597 |
+
" <td>NoHR</td>\n",
|
1598 |
+
" <td>0.325278</td>\n",
|
1599 |
+
" <td>NaN</td>\n",
|
1600 |
+
" </tr>\n",
|
1601 |
+
" </tbody>\n",
|
1602 |
+
"</table>\n",
|
1603 |
+
"<p>5 rows × 98 columns</p>\n",
|
1604 |
+
"</div>"
|
1605 |
+
],
|
1606 |
+
"text/plain": [
|
1607 |
+
" Activity ID Activity Date Activity Name Activity Type Description \\\n",
|
1608 |
+
"0 8280988291 2022-12-23 06:57:23 午後のランニング ランニング NaN \n",
|
1609 |
+
"1 8286585787 2022-12-24 09:57:04 夕方の水泳 水泳 NaN \n",
|
1610 |
+
"2 8293206227 2022-12-26 10:42:37 夕方の水泳 水�� NaN \n",
|
1611 |
+
"3 8314368113 2022-12-31 06:05:56 午後のライド ライド NaN \n",
|
1612 |
+
"4 8330224933 2023-01-01 06:53:06 午後のライド ライド NaN \n",
|
1613 |
+
"\n",
|
1614 |
+
" Elapsed Time Distance Max Heart Rate Relative Effort Commute ... \\\n",
|
1615 |
+
"0 1530 4.62 NaN NaN False ... \n",
|
1616 |
+
"1 4454 1150.00 NaN NaN False ... \n",
|
1617 |
+
"2 4556 550.00 NaN NaN False ... \n",
|
1618 |
+
"3 1897 9.10 NaN NaN False ... \n",
|
1619 |
+
"4 1222 7.62 NaN NaN False ... \n",
|
1620 |
+
"\n",
|
1621 |
+
" Training Load Intensity Grade Adjusted Pace (Average) Timer Time \\\n",
|
1622 |
+
"0 NaN NaN NaN NaN \n",
|
1623 |
+
"1 NaN NaN NaN NaN \n",
|
1624 |
+
"2 NaN NaN NaN NaN \n",
|
1625 |
+
"3 NaN NaN NaN NaN \n",
|
1626 |
+
"4 NaN NaN NaN NaN \n",
|
1627 |
+
"\n",
|
1628 |
+
" Total Cycles Media intensity_level training_category moving_hr trimp \n",
|
1629 |
+
"0 NaN NaN NaN NoHR 0.421944 NaN \n",
|
1630 |
+
"1 NaN NaN NaN NoHR 0.446111 NaN \n",
|
1631 |
+
"2 NaN NaN NaN NoHR 0.400278 NaN \n",
|
1632 |
+
"3 NaN NaN NaN NoHR 0.454722 NaN \n",
|
1633 |
+
"4 NaN NaN NaN NoHR 0.325278 NaN \n",
|
1634 |
+
"\n",
|
1635 |
+
"[5 rows x 98 columns]"
|
1636 |
+
]
|
1637 |
+
},
|
1638 |
+
"execution_count": 9,
|
1639 |
+
"metadata": {},
|
1640 |
+
"output_type": "execute_result"
|
1641 |
+
}
|
1642 |
+
],
|
1643 |
+
"source": [
|
1644 |
+
"df.head()"
|
1645 |
+
]
|
1646 |
+
},
|
1647 |
+
{
|
1648 |
+
"cell_type": "code",
|
1649 |
+
"execution_count": 10,
|
1650 |
+
"id": "47335ec0",
|
1651 |
+
"metadata": {},
|
1652 |
+
"outputs": [
|
1653 |
+
{
|
1654 |
+
"name": "stdout",
|
1655 |
+
"output_type": "stream",
|
1656 |
+
"text": [
|
1657 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
1658 |
+
"RangeIndex: 474 entries, 0 to 473\n",
|
1659 |
+
"Data columns (total 98 columns):\n",
|
1660 |
+
" # Column Non-Null Count Dtype \n",
|
1661 |
+
"--- ------ -------------- ----- \n",
|
1662 |
+
" 0 Activity ID 474 non-null int64 \n",
|
1663 |
+
" 1 Activity Date 474 non-null datetime64[ns]\n",
|
1664 |
+
" 2 Activity Name 474 non-null object \n",
|
1665 |
+
" 3 Activity Type 474 non-null object \n",
|
1666 |
+
" 4 Description 0 non-null float64 \n",
|
1667 |
+
" 5 Elapsed Time 474 non-null int32 \n",
|
1668 |
+
" 6 Distance 474 non-null float32 \n",
|
1669 |
+
" 7 Max Heart Rate 0 non-null float64 \n",
|
1670 |
+
" 8 Relative Effort 0 non-null float64 \n",
|
1671 |
+
" 9 Commute 474 non-null bool \n",
|
1672 |
+
" 10 Activity Private Notes 0 non-null float64 \n",
|
1673 |
+
" 11 Gear 0 non-null float64 \n",
|
1674 |
+
" 12 Filename 474 non-null object \n",
|
1675 |
+
" 13 Athlete Weight 0 non-null float64 \n",
|
1676 |
+
" 14 Bike Weight 0 non-null float64 \n",
|
1677 |
+
" 15 Elapsed Time.1 474 non-null float64 \n",
|
1678 |
+
" 16 Moving Time 474 non-null int32 \n",
|
1679 |
+
" 17 Distance.1 474 non-null float64 \n",
|
1680 |
+
" 18 Max Speed 474 non-null float64 \n",
|
1681 |
+
" 19 Average Speed 474 non-null float64 \n",
|
1682 |
+
" 20 Elevation Gain 474 non-null float64 \n",
|
1683 |
+
" 21 Elevation Loss 372 non-null float64 \n",
|
1684 |
+
" 22 Min Elevation 372 non-null float64 \n",
|
1685 |
+
" 23 Max Elevation 372 non-null float64 \n",
|
1686 |
+
" 24 Max Grade 474 non-null float64 \n",
|
1687 |
+
" 25 Average Grade 474 non-null float64 \n",
|
1688 |
+
" 26 Average Positive Grade 0 non-null float64 \n",
|
1689 |
+
" 27 Average Negative Grade 0 non-null float64 \n",
|
1690 |
+
" 28 Max Cadence 147 non-null float64 \n",
|
1691 |
+
" 29 Average Cadence 260 non-null float64 \n",
|
1692 |
+
" 30 Max Heart Rate.1 0 non-null float64 \n",
|
1693 |
+
" 31 Average Heart Rate 0 non-null float64 \n",
|
1694 |
+
" 32 Max Power 0 non-null float64 \n",
|
1695 |
+
" 33 Average Power 114 non-null float64 \n",
|
1696 |
+
" 34 Calories 465 non-null float64 \n",
|
1697 |
+
" 35 Max Temperature 0 non-null float64 \n",
|
1698 |
+
" 36 Average Temperature 20 non-null float64 \n",
|
1699 |
+
" 37 Relative Effort.1 0 non-null float64 \n",
|
1700 |
+
" 38 Total Work 115 non-null float64 \n",
|
1701 |
+
" 39 Number of Runs 0 non-null float64 \n",
|
1702 |
+
" 40 Uphill Time 0 non-null float64 \n",
|
1703 |
+
" 41 Downhill Time 0 non-null float64 \n",
|
1704 |
+
" 42 Other Time 0 non-null float64 \n",
|
1705 |
+
" 43 Perceived Exertion 0 non-null float64 \n",
|
1706 |
+
" 44 Device Type 0 non-null float64 \n",
|
1707 |
+
" 45 Start Time 0 non-null float64 \n",
|
1708 |
+
" 46 Weighted Average Power 114 non-null float64 \n",
|
1709 |
+
" 47 Power Count 114 non-null float64 \n",
|
1710 |
+
" 48 Perceived Exertion Used 0 non-null float64 \n",
|
1711 |
+
" 49 Perceived Relative Effort 0 non-null float64 \n",
|
1712 |
+
" 50 Commute.1 474 non-null float64 \n",
|
1713 |
+
" 51 Total Weight 0 non-null float64 \n",
|
1714 |
+
" 52 Weather Observed 474 non-null float64 \n",
|
1715 |
+
" 53 Grade Adjusted Pace 116 non-null float64 \n",
|
1716 |
+
" 54 Observation Time 5 non-null float64 \n",
|
1717 |
+
" 55 Weather 5 non-null float64 \n",
|
1718 |
+
" 56 Average Temperature.1 5 non-null float64 \n",
|
1719 |
+
" 57 Apparent Temperature 5 non-null float64 \n",
|
1720 |
+
" 58 Dew Point 5 non-null float64 \n",
|
1721 |
+
" 59 Humidity 5 non-null float64 \n",
|
1722 |
+
" 60 Pressure 5 non-null float64 \n",
|
1723 |
+
" 61 Wind Speed 5 non-null float64 \n",
|
1724 |
+
" 62 Wind Gust 5 non-null float64 \n",
|
1725 |
+
" 63 Wind Bearing 5 non-null float64 \n",
|
1726 |
+
" 64 Precipitation 5 non-null float64 \n",
|
1727 |
+
" 65 Sunset Time 5 non-null float64 \n",
|
1728 |
+
" 66 Sunrise Time 5 non-null float64 \n",
|
1729 |
+
" 67 Moon Phase 5 non-null float64 \n",
|
1730 |
+
" 68 自転車 0 non-null float64 \n",
|
1731 |
+
" 69 Gear.1 0 non-null float64 \n",
|
1732 |
+
" 70 Precipitation Probability 5 non-null float64 \n",
|
1733 |
+
" 71 Precipitation Type 5 non-null float64 \n",
|
1734 |
+
" 72 Cloud Cover 5 non-null float64 \n",
|
1735 |
+
" 73 Visibility 5 non-null float64 \n",
|
1736 |
+
" 74 UV Index 5 non-null float64 \n",
|
1737 |
+
" 75 Ozone 0 non-null float64 \n",
|
1738 |
+
" 76 Jump Count 0 non-null float64 \n",
|
1739 |
+
" 77 Total Grit 0 non-null float64 \n",
|
1740 |
+
" 78 Average Flow 0 non-null float64 \n",
|
1741 |
+
" 79 Flagged 474 non-null float64 \n",
|
1742 |
+
" 80 Average Elapsed Speed 474 non-null float64 \n",
|
1743 |
+
" 81 Dirt Distance 474 non-null float64 \n",
|
1744 |
+
" 82 Newly Explored Distance 0 non-null float64 \n",
|
1745 |
+
" 83 Newly Explored Dirt Distance 0 non-null float64 \n",
|
1746 |
+
" 84 Activity Count 0 non-null float64 \n",
|
1747 |
+
" 85 Step Count 28 non-null float64 \n",
|
1748 |
+
" 86 Carbon Savings 0 non-null float64 \n",
|
1749 |
+
" 87 Pool Length 31 non-null float64 \n",
|
1750 |
+
" 88 Training Load 0 non-null float64 \n",
|
1751 |
+
" 89 Intensity 0 non-null float64 \n",
|
1752 |
+
" 90 Grade Adjusted Pace (Average) 27 non-null float64 \n",
|
1753 |
+
" 91 Timer Time 0 non-null float64 \n",
|
1754 |
+
" 92 Total Cycles 70 non-null float64 \n",
|
1755 |
+
" 93 Media 0 non-null float64 \n",
|
1756 |
+
" 94 intensity_level 0 non-null float64 \n",
|
1757 |
+
" 95 training_category 474 non-null category \n",
|
1758 |
+
" 96 moving_hr 474 non-null float64 \n",
|
1759 |
+
" 97 trimp 0 non-null float64 \n",
|
1760 |
+
"dtypes: bool(1), category(1), datetime64[ns](1), float32(1), float64(88), int32(2), int64(1), object(3)\n",
|
1761 |
+
"memory usage: 351.2+ KB\n"
|
1762 |
+
]
|
1763 |
+
}
|
1764 |
+
],
|
1765 |
+
"source": [
|
1766 |
+
"df.info() "
|
1767 |
+
]
|
1768 |
+
},
|
1769 |
+
{
|
1770 |
+
"cell_type": "code",
|
1771 |
+
"execution_count": null,
|
1772 |
+
"id": "eebf9653",
|
1773 |
+
"metadata": {},
|
1774 |
+
"outputs": [],
|
1775 |
+
"source": []
|
1776 |
}
|
1777 |
],
|
1778 |
"metadata": {
|