{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-09-10T09:35:11.246238Z","iopub.execute_input":"2023-09-10T09:35:11.246627Z","iopub.status.idle":"2023-09-10T09:35:11.648602Z","shell.execute_reply.started":"2023-09-10T09:35:11.246596Z","shell.execute_reply":"2023-09-10T09:35:11.647266Z"},"trusted":true},"execution_count":1,"outputs":[{"name":"stdout","text":"/kaggle/input/child-mind-institute-detect-sleep-states/train_series.parquet\n/kaggle/input/child-mind-institute-detect-sleep-states/sample_submission.csv\n/kaggle/input/child-mind-institute-detect-sleep-states/train_events.csv\n/kaggle/input/child-mind-institute-detect-sleep-states/test_series.parquet\n","output_type":"stream"}]},{"cell_type":"code","source":"import pandas as pd","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:07:32.313233Z","iopub.execute_input":"2023-09-10T15:07:32.313651Z","iopub.status.idle":"2023-09-10T15:07:32.738796Z","shell.execute_reply.started":"2023-09-10T15:07:32.313617Z","shell.execute_reply":"2023-09-10T15:07:32.737562Z"},"trusted":true},"execution_count":1,"outputs":[]},{"cell_type":"code","source":"train_csv = pd.read_csv(r'/kaggle/input/child-mind-institute-detect-sleep-states/train_events.csv')","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:08:17.159613Z","iopub.execute_input":"2023-09-10T15:08:17.160719Z","iopub.status.idle":"2023-09-10T15:08:17.189091Z","shell.execute_reply.started":"2023-09-10T15:08:17.160683Z","shell.execute_reply":"2023-09-10T15:08:17.187971Z"},"trusted":true},"execution_count":4,"outputs":[]},{"cell_type":"code","source":"train_parq = pd.read_parquet(r'/kaggle/input/child-mind-institute-detect-sleep-states/train_series.parquet')","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:09:57.968768Z","iopub.execute_input":"2023-09-10T15:09:57.969122Z","iopub.status.idle":"2023-09-10T15:10:47.425076Z","shell.execute_reply.started":"2023-09-10T15:09:57.969093Z","shell.execute_reply":"2023-09-10T15:10:47.424254Z"},"trusted":true},"execution_count":8,"outputs":[]},{"cell_type":"code","source":"train_parq","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:10:47.447986Z","iopub.execute_input":"2023-09-10T15:10:47.448484Z","iopub.status.idle":"2023-09-10T15:10:47.464033Z","shell.execute_reply.started":"2023-09-10T15:10:47.448454Z","shell.execute_reply":"2023-09-10T15:10:47.462698Z"},"trusted":true},"execution_count":10,"outputs":[{"execution_count":10,"output_type":"execute_result","data":{"text/plain":"              series_id    step                 timestamp     anglez    enmo\n0          038441c925bb       0  2018-08-14T15:30:00-0400   2.636700  0.0217\n1          038441c925bb       1  2018-08-14T15:30:05-0400   2.636800  0.0215\n2          038441c925bb       2  2018-08-14T15:30:10-0400   2.637000  0.0216\n3          038441c925bb       3  2018-08-14T15:30:15-0400   2.636800  0.0213\n4          038441c925bb       4  2018-08-14T15:30:20-0400   2.636800  0.0215\n...                 ...     ...                       ...        ...     ...\n127946335  fe90110788d2  592375  2017-09-08T00:14:35-0400 -27.277500  0.0204\n127946336  fe90110788d2  592376  2017-09-08T00:14:40-0400 -27.032499  0.0233\n127946337  fe90110788d2  592377  2017-09-08T00:14:45-0400 -26.841200  0.0202\n127946338  fe90110788d2  592378  2017-09-08T00:14:50-0400 -26.723900  0.0199\n127946339  fe90110788d2  592379  2017-09-08T00:14:55-0400 -31.521601  0.0205\n\n[127946340 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>series_id</th>\n      <th>step</th>\n      <th>timestamp</th>\n      <th>anglez</th>\n      <th>enmo</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>038441c925bb</td>\n      <td>0</td>\n      <td>2018-08-14T15:30:00-0400</td>\n      <td>2.636700</td>\n      <td>0.0217</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>038441c925bb</td>\n      <td>1</td>\n      <td>2018-08-14T15:30:05-0400</td>\n      <td>2.636800</td>\n      <td>0.0215</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>038441c925bb</td>\n      <td>2</td>\n      <td>2018-08-14T15:30:10-0400</td>\n      <td>2.637000</td>\n      <td>0.0216</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>038441c925bb</td>\n      <td>3</td>\n      <td>2018-08-14T15:30:15-0400</td>\n      <td>2.636800</td>\n      <td>0.0213</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>038441c925bb</td>\n      <td>4</td>\n      <td>2018-08-14T15:30:20-0400</td>\n      <td>2.636800</td>\n      <td>0.0215</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>127946335</th>\n      <td>fe90110788d2</td>\n      <td>592375</td>\n      <td>2017-09-08T00:14:35-0400</td>\n      <td>-27.277500</td>\n      <td>0.0204</td>\n    </tr>\n    <tr>\n      <th>127946336</th>\n      <td>fe90110788d2</td>\n      <td>592376</td>\n      <td>2017-09-08T00:14:40-0400</td>\n      <td>-27.032499</td>\n      <td>0.0233</td>\n    </tr>\n    <tr>\n      <th>127946337</th>\n      <td>fe90110788d2</td>\n      <td>592377</td>\n      <td>2017-09-08T00:14:45-0400</td>\n      <td>-26.841200</td>\n      <td>0.0202</td>\n    </tr>\n    <tr>\n      <th>127946338</th>\n      <td>fe90110788d2</td>\n      <td>592378</td>\n      <td>2017-09-08T00:14:50-0400</td>\n      <td>-26.723900</td>\n      <td>0.0199</td>\n    </tr>\n    <tr>\n      <th>127946339</th>\n      <td>fe90110788d2</td>\n      <td>592379</td>\n      <td>2017-09-08T00:14:55-0400</td>\n      <td>-31.521601</td>\n      <td>0.0205</td>\n    </tr>\n  </tbody>\n</table>\n<p>127946340 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"train_parq['series_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:16:54.82643Z","iopub.execute_input":"2023-09-10T15:16:54.82673Z","iopub.status.idle":"2023-09-10T15:17:10.575467Z","shell.execute_reply.started":"2023-09-10T15:16:54.826704Z","shell.execute_reply":"2023-09-10T15:17:10.574362Z"},"trusted":true},"execution_count":13,"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"series_id\n78569a801a38    1433880\nf564985ab692    1052820\nfb223ed2278c     918360\nf56824b503a0     846360\ncfeb11428dd7     809820\n                 ...   \nc535634d7dcd     136080\n1c7c0bad1263     115380\n60e51cad2ffb     113940\n3a9a9dc2cbd9     103500\n349c5562ee2c      37080\nName: count, Length: 277, dtype: int64"},"metadata":{}}]},{"cell_type":"code","source":"train_csv['series_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:16:22.154146Z","iopub.execute_input":"2023-09-10T15:16:22.154658Z","iopub.status.idle":"2023-09-10T15:16:22.171502Z","shell.execute_reply.started":"2023-09-10T15:16:22.154614Z","shell.execute_reply":"2023-09-10T15:16:22.17036Z"},"trusted":true},"execution_count":11,"outputs":[{"execution_count":11,"output_type":"execute_result","data":{"text/plain":"series_id\n78569a801a38    168\nf564985ab692    124\nfb223ed2278c    106\nf56824b503a0    100\ncfeb11428dd7     94\n               ... \n3a9a9dc2cbd9     12\n60e51cad2ffb     10\n13b4d6a01d27     10\n10469f6765bf      8\n349c5562ee2c      4\nName: count, Length: 277, dtype: int64"},"metadata":{}}]},{"cell_type":"code","source":"train_csv","metadata":{"execution":{"iopub.status.busy":"2023-09-10T15:08:21.734122Z","iopub.execute_input":"2023-09-10T15:08:21.734515Z","iopub.status.idle":"2023-09-10T15:08:21.754532Z","shell.execute_reply.started":"2023-09-10T15:08:21.734484Z","shell.execute_reply":"2023-09-10T15:08:21.753468Z"},"trusted":true},"execution_count":6,"outputs":[{"execution_count":6,"output_type":"execute_result","data":{"text/plain":"          series_id  night   event      step                 timestamp\n0      038441c925bb      1   onset    4992.0  2018-08-14T22:26:00-0400\n1      038441c925bb      1  wakeup   10932.0  2018-08-15T06:41:00-0400\n2      038441c925bb      2   onset   20244.0  2018-08-15T19:37:00-0400\n3      038441c925bb      2  wakeup   27492.0  2018-08-16T05:41:00-0400\n4      038441c925bb      3   onset   39996.0  2018-08-16T23:03:00-0400\n...             ...    ...     ...       ...                       ...\n14505  fe90110788d2     33  wakeup  560604.0  2017-09-06T04:07:00-0400\n14506  fe90110788d2     34   onset  574620.0  2017-09-06T23:35:00-0400\n14507  fe90110788d2     34  wakeup  581604.0  2017-09-07T09:17:00-0400\n14508  fe90110788d2     35   onset       NaN                       NaN\n14509  fe90110788d2     35  wakeup       NaN                       NaN\n\n[14510 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>series_id</th>\n      <th>night</th>\n      <th>event</th>\n      <th>step</th>\n      <th>timestamp</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>038441c925bb</td>\n      <td>1</td>\n      <td>onset</td>\n      <td>4992.0</td>\n      <td>2018-08-14T22:26:00-0400</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>038441c925bb</td>\n      <td>1</td>\n      <td>wakeup</td>\n      <td>10932.0</td>\n      <td>2018-08-15T06:41:00-0400</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>038441c925bb</td>\n      <td>2</td>\n      <td>onset</td>\n      <td>20244.0</td>\n      <td>2018-08-15T19:37:00-0400</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>038441c925bb</td>\n      <td>2</td>\n      <td>wakeup</td>\n      <td>27492.0</td>\n      <td>2018-08-16T05:41:00-0400</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>038441c925bb</td>\n      <td>3</td>\n      <td>onset</td>\n      <td>39996.0</td>\n      <td>2018-08-16T23:03:00-0400</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>14505</th>\n      <td>fe90110788d2</td>\n      <td>33</td>\n      <td>wakeup</td>\n      <td>560604.0</td>\n      <td>2017-09-06T04:07:00-0400</td>\n    </tr>\n    <tr>\n      <th>14506</th>\n      <td>fe90110788d2</td>\n      <td>34</td>\n      <td>onset</td>\n      <td>574620.0</td>\n      <td>2017-09-06T23:35:00-0400</td>\n    </tr>\n    <tr>\n      <th>14507</th>\n      <td>fe90110788d2</td>\n      <td>34</td>\n      <td>wakeup</td>\n      <td>581604.0</td>\n      <td>2017-09-07T09:17:00-0400</td>\n    </tr>\n    <tr>\n      <th>14508</th>\n      <td>fe90110788d2</td>\n      <td>35</td>\n      <td>onset</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>14509</th>\n      <td>fe90110788d2</td>\n      <td>35</td>\n      <td>wakeup</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n<p>14510 rows × 5 columns</p>\n</div>"},"metadata":{}}]}]}