{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# [Objective]\n- This notebook is for EDA train_events.csv\n\n# [Contents]\n- 1. Import libraries\n- 2. Read event & preprocess  \n    convert timeseries column str -> datetime[μs]\n      \n- 3. Check each columns  \n    - 3.1. series_id  \n    - 3.2. night  \n    - 3.3. onset & wakeup  \n    - 3.4. step  \n    - 3.5. timestamp","metadata":{}},{"cell_type":"markdown","source":"# 1. 📚 Import Libraries","metadata":{}},{"cell_type":"code","source":"# =================\n# import libraries\n# =================\nimport numpy as np \nimport pandas as pd\nimport polars as pl\n\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-31T14:04:33.789685Z","iopub.execute_input":"2023-10-31T14:04:33.790236Z","iopub.status.idle":"2023-10-31T14:04:33.804721Z","shell.execute_reply.started":"2023-10-31T14:04:33.790196Z","shell.execute_reply":"2023-10-31T14:04:33.803229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def show_df(df, num=3, tail=True):\n    print(df.shape)\n    display(df.head(num))\n    if tail:\n        display(df.tail(num))","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:33.807648Z","iopub.execute_input":"2023-10-31T14:04:33.808120Z","iopub.status.idle":"2023-10-31T14:04:33.816069Z","shell.execute_reply.started":"2023-10-31T14:04:33.808085Z","shell.execute_reply":"2023-10-31T14:04:33.814428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 2. 🔧 Read event & preprocess","metadata":{}},{"cell_type":"code","source":"# read event\nevents = pl.read_csv(\"/kaggle/input/child-mind-institute-detect-sleep-states/train_events.csv\")\nprint(\"=\"*80); print(\"events\"); print(\"=\"*80); show_df(events)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:33.820691Z","iopub.execute_input":"2023-10-31T14:04:33.821945Z","iopub.status.idle":"2023-10-31T14:04:33.873518Z","shell.execute_reply.started":"2023-10-31T14:04:33.821888Z","shell.execute_reply":"2023-10-31T14:04:33.871772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# show timestamp (example)\nfor i in range(3):\n    print(events[\"timestamp\"][i])","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:33.875796Z","iopub.execute_input":"2023-10-31T14:04:33.877274Z","iopub.status.idle":"2023-10-31T14:04:33.885085Z","shell.execute_reply.started":"2023-10-31T14:04:33.877230Z","shell.execute_reply":"2023-10-31T14:04:33.883767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# convert str -> datetime(ns)\nimport datetime\nevents = events.with_columns(\n    pl.col(\"timestamp\").apply(lambda x: x[-5:]).alias(\"timezone_offset\"),\n    pl.col(\"timestamp\").apply(lambda x: datetime.datetime.strptime(str(x), '%Y-%m-%dT%H:%M:%S%z')).alias(\"timestamp\"),\n)\n\nshow_df(events)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:33.890187Z","iopub.execute_input":"2023-10-31T14:04:33.891421Z","iopub.status.idle":"2023-10-31T14:04:34.200868Z","shell.execute_reply.started":"2023-10-31T14:04:33.891364Z","shell.execute_reply":"2023-10-31T14:04:34.199896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# basic statistics(event)\nprint(\"=\"*80); print(\"basic statistics(event)\"); print(\"=\"*80); print(events.describe())","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:34.202621Z","iopub.execute_input":"2023-10-31T14:04:34.202967Z","iopub.status.idle":"2023-10-31T14:04:34.216633Z","shell.execute_reply.started":"2023-10-31T14:04:34.202937Z","shell.execute_reply":"2023-10-31T14:04:34.215087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# divide timestamp -> year / month / day / hour / minute / second\nevents = events.with_columns(\n    events['timestamp'].apply(lambda x: x.year).alias(\"year\"),\n    events['timestamp'].apply(lambda x: x.month).alias(\"month\"),\n    events['timestamp'].apply(lambda x: x.day).alias(\"day\"),\n    events['timestamp'].apply(lambda x: x.hour).alias(\"hour\"),\n    events['timestamp'].apply(lambda x: x.minute).alias(\"minute\"),\n    events['timestamp'].apply(lambda x: x.second).alias(\"second\"),\n)\n\nshow_df(events)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:34.218587Z","iopub.execute_input":"2023-10-31T14:04:34.219142Z","iopub.status.idle":"2023-10-31T14:04:34.402802Z","shell.execute_reply.started":"2023-10-31T14:04:34.219098Z","shell.execute_reply":"2023-10-31T14:04:34.401512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> There are some rows which timestamp is null -> Could we use these rows or not ??","metadata":{}},{"cell_type":"code","source":"# basic statistics(event)\nprint(\"=\"*80); print(\"basic statistics(event)\"); print(\"=\"*80); \nprint(events.select([\"year\", \"month\", \"day\", \"minute\", \"second\"]).describe())","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:34.405129Z","iopub.execute_input":"2023-10-31T14:04:34.405656Z","iopub.status.idle":"2023-10-31T14:04:34.418159Z","shell.execute_reply.started":"2023-10-31T14:04:34.405610Z","shell.execute_reply":"2023-10-31T14:04:34.416845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 3. 🧐 Check each columns","metadata":{}},{"cell_type":"markdown","source":"## 3.1. series_id\n- Unique identifier for each accelerometer series.","metadata":{}},{"cell_type":"code","source":"series_id = events[\"series_id\"].unique()\nprint(f\"Number of series_id : {len(series_id)}\")\nprint(\"Examples\"); print(\"=\"*80); print(series_id[:10])","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:34.420557Z","iopub.execute_input":"2023-10-31T14:04:34.421055Z","iopub.status.idle":"2023-10-31T14:04:34.431639Z","shell.execute_reply.started":"2023-10-31T14:04:34.421007Z","shell.execute_reply":"2023-10-31T14:04:34.430103Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# read train\ntrain = pl.read_parquet(\"/kaggle/input/child-mind-institute-detect-sleep-states/train_series.parquet\")\nprint(\"=\"*80); print(\"train\"); print(\"=\"*80); show_df(train, 3, False)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:04:34.438839Z","iopub.execute_input":"2023-10-31T14:04:34.439354Z","iopub.status.idle":"2023-10-31T14:05:01.110836Z","shell.execute_reply.started":"2023-10-31T14:04:34.439306Z","shell.execute_reply":"2023-10-31T14:05:01.109255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# read test\ntest = pl.read_parquet(\"/kaggle/input/child-mind-institute-detect-sleep-states/test_series.parquet\")\nprint(\"=\"*80); print(\"test\"); print(\"=\"*80); show_df(test, 3, False)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:01.113047Z","iopub.execute_input":"2023-10-31T14:05:01.114398Z","iopub.status.idle":"2023-10-31T14:05:01.130766Z","shell.execute_reply.started":"2023-10-31T14:05:01.114347Z","shell.execute_reply":"2023-10-31T14:05:01.129213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# read sumple submission\nsub = pl.read_csv(\"/kaggle/input/child-mind-institute-detect-sleep-states/sample_submission.csv\")\nprint(\"=\"*80); print(\"sub\"); print(\"=\"*80); show_df(sub, 3, False)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:01.132673Z","iopub.execute_input":"2023-10-31T14:05:01.133353Z","iopub.status.idle":"2023-10-31T14:05:01.146063Z","shell.execute_reply.started":"2023-10-31T14:05:01.133066Z","shell.execute_reply":"2023-10-31T14:05:01.144609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"series_id_train = train[\"series_id\"].unique()\nprint(f\"Number of series_id_train : {len(series_id_train)}\")\nprint(\"Examples\"); print(\"=\"*80); print(series_id_train[:10])","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:01.148671Z","iopub.execute_input":"2023-10-31T14:05:01.149205Z","iopub.status.idle":"2023-10-31T14:05:03.512763Z","shell.execute_reply.started":"2023-10-31T14:05:01.149167Z","shell.execute_reply":"2023-10-31T14:05:03.511458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"series_id_test = test[\"series_id\"].unique()\nprint(f\"Number of series_id_test : {len(series_id_test)}\")\nprint(\"Examples\"); print(\"=\"*80); print(series_id_test[:10])","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:03.514359Z","iopub.execute_input":"2023-10-31T14:05:03.514729Z","iopub.status.idle":"2023-10-31T14:05:03.524687Z","shell.execute_reply.started":"2023-10-31T14:05:03.514697Z","shell.execute_reply":"2023-10-31T14:05:03.523125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"series_id_sub = sub[\"series_id\"].unique()\nprint(f\"Number of series_id_sub : {len(series_id_sub)}\")\nprint(\"Examples\"); print(\"=\"*80); print(series_id_sub[:10])","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:03.526512Z","iopub.execute_input":"2023-10-31T14:05:03.527046Z","iopub.status.idle":"2023-10-31T14:05:03.543719Z","shell.execute_reply.started":"2023-10-31T14:05:03.526994Z","shell.execute_reply":"2023-10-31T14:05:03.542174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# check same series_id in events & train\nduplicated_id = set(set(series_id_train)&set(series_id))\nprint(f\"Number of duplicated_id : {len(duplicated_id)}\")","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:03.545660Z","iopub.execute_input":"2023-10-31T14:05:03.546102Z","iopub.status.idle":"2023-10-31T14:05:03.567440Z","shell.execute_reply.started":"2023-10-31T14:05:03.546069Z","shell.execute_reply":"2023-10-31T14:05:03.565706Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> All series_id in events is in train","metadata":{}},{"cell_type":"code","source":"# check same series_id in events & test\nduplicated_id = set(set(series_id_test)&set(series_id))\nprint(f\"Number of duplicated_id : {len(duplicated_id)}\")","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:03.572533Z","iopub.execute_input":"2023-10-31T14:05:03.572995Z","iopub.status.idle":"2023-10-31T14:05:03.581702Z","shell.execute_reply.started":"2023-10-31T14:05:03.572960Z","shell.execute_reply":"2023-10-31T14:05:03.580248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> All series_id in test sample is in events (= in train)","metadata":{}},{"cell_type":"code","source":"# check same series_id in events & test\nduplicated_id = set(set(series_id_sub)&set(series_id))\nprint(f\"Number of duplicated_id : {len(duplicated_id)}\")","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:03.583418Z","iopub.execute_input":"2023-10-31T14:05:03.583814Z","iopub.status.idle":"2023-10-31T14:05:03.598253Z","shell.execute_reply.started":"2023-10-31T14:05:03.583781Z","shell.execute_reply":"2023-10-31T14:05:03.596754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 3.2. night\n- An enumeration of potential onset / wakeup event pairs. At most one pair of events can occur for each night.","metadata":{}},{"cell_type":"code","source":"from matplotlib import pyplot as plt\n\ndef show_hist(df:pd.DataFrame, col:str, title:str=None, xlim:list=[None,None], bins=20)->None:\n    \"\"\"show histgram\n\n    Args:\n        df (pl.DataFrame): input data\n        col (str): show column\n        title (str, optional): title. Defaults to None.\n        xlim (list, optional): range of x-axis. Defaults to [None,None].\n    \"\"\"\n    fig = plt.figure(figsize=[20,4])\n    tmp = df[col].to_numpy()\n    plt.hist(tmp, alpha=0.5, range=(xlim[0], xlim[1]), bins=bins)  # 範囲とビンの数を指定\n    plt.title(title) # カラム名をタイトルとして設定\n    plt.xlabel(col)\n    plt.xlim(xlim) ","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:19:15.257103Z","iopub.execute_input":"2023-10-31T14:19:15.257641Z","iopub.status.idle":"2023-10-31T14:19:15.269565Z","shell.execute_reply.started":"2023-10-31T14:19:15.257605Z","shell.execute_reply":"2023-10-31T14:19:15.267970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_hist(events, \"night\", \"night distribution\", [0,100], 100)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:19:15.719392Z","iopub.execute_input":"2023-10-31T14:19:15.720391Z","iopub.status.idle":"2023-10-31T14:19:16.241306Z","shell.execute_reply.started":"2023-10-31T14:19:15.720353Z","shell.execute_reply":"2023-10-31T14:19:16.240270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def show_lineplot(df, xlabel, ylabel, title=None):\n    # Matplotlibを使用してLine Plotを描画\n    plt.figure(figsize=(20, 4))\n    plt.plot(df[xlabel], df[ylabel], marker='o', linestyle='-')\n\n    # タイトルと軸ラベルを設定\n    plt.title(title)\n    plt.xlabel(xlabel)\n    plt.ylabel(ylabel)\n\n    # グリッドを表示\n    plt.grid(True)\n    # グラフを表示\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:04.140528Z","iopub.execute_input":"2023-10-31T14:05:04.141860Z","iopub.status.idle":"2023-10-31T14:05:04.151693Z","shell.execute_reply.started":"2023-10-31T14:05:04.141810Z","shell.execute_reply":"2023-10-31T14:05:04.150098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for idx in range(10):\n    tmp = events.filter(pl.col(\"series_id\")==series_id[idx])\n    show_lineplot(tmp, \"timestamp\", \"night\", \"timestamp vs night\")","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:04.154974Z","iopub.execute_input":"2023-10-31T14:05:04.155427Z","iopub.status.idle":"2023-10-31T14:05:09.949879Z","shell.execute_reply.started":"2023-10-31T14:05:04.155391Z","shell.execute_reply":"2023-10-31T14:05:09.948571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 3.3. onset & wakeup\n- The type of event, whether onset or wakeup.","metadata":{}},{"cell_type":"code","source":"events = events.with_columns(\n    events['event'].apply(lambda x: 1 if x==\"onset\" else 0).alias(\"onset\"),\n    events['event'].apply(lambda x: 1 if x==\"wakeup\" else 0).alias(\"wakeup\"),\n)\nshow_df(events.select([\"event\", \"onset\", \"wakeup\"]))","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:09.951770Z","iopub.execute_input":"2023-10-31T14:05:09.952198Z","iopub.status.idle":"2023-10-31T14:05:09.989323Z","shell.execute_reply.started":"2023-10-31T14:05:09.952162Z","shell.execute_reply":"2023-10-31T14:05:09.987799Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def show_lineplot2(df, xlabel, ylabel, title=None):\n    _onset = df.filter(pl.col(\"event\")== 'onset')['timestamp'].to_numpy()\n    _wakeup = df.filter(pl.col(\"event\")== 'wakeup')['timestamp'].to_numpy()\n    # Matplotlibを使用してLine Plotを描画\n    plt.figure(figsize=(20, 4))\n    plt.plot(df[xlabel], df[ylabel], marker='o', linestyle='-')\n    for onset in _onset:\n        plt.axvline(x=onset, color='r', linestyle='--', label='onset')\n    for wakeup in _wakeup:\n        plt.axvline(x=wakeup, color='g', linestyle='--', label='wakeup')\n\n    # タイトルと軸ラベルを設定\n    plt.title(title)\n    plt.xlabel(xlabel)\n    plt.ylabel(ylabel)\n\n    # グリッドを表示\n    plt.grid(True)\n    # グラフを表示\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:09.991277Z","iopub.execute_input":"2023-10-31T14:05:09.991930Z","iopub.status.idle":"2023-10-31T14:05:10.003711Z","shell.execute_reply.started":"2023-10-31T14:05:09.991894Z","shell.execute_reply":"2023-10-31T14:05:10.001731Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for idx in range(10):\n    tmp = events.filter(pl.col(\"series_id\")==series_id[idx])\n    show_lineplot2(tmp, \"timestamp\", \"night\", \"timestamp vs night with event\")","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:10.011237Z","iopub.execute_input":"2023-10-31T14:05:10.011858Z","iopub.status.idle":"2023-10-31T14:05:15.479713Z","shell.execute_reply.started":"2023-10-31T14:05:10.011814Z","shell.execute_reply":"2023-10-31T14:05:15.478169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 3.4. step\n- The recorded time of occurence of the event in the accelerometer series.\n","metadata":{}},{"cell_type":"code","source":"for idx in range(10):\n    tmp = events.filter(pl.col(\"series_id\")==series_id[idx])\n    show_lineplot(tmp, \"timestamp\", \"step\", \"timestamp vs step\")","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:15.481492Z","iopub.execute_input":"2023-10-31T14:05:15.482048Z","iopub.status.idle":"2023-10-31T14:05:19.675989Z","shell.execute_reply.started":"2023-10-31T14:05:15.481984Z","shell.execute_reply":"2023-10-31T14:05:19.674695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 3.5. timestamp\n- The recorded time of occurence of the event in the accelerometer series.\n","metadata":{}},{"cell_type":"markdown","source":"### 3.5.1. timezone_offset","metadata":{}},{"cell_type":"code","source":"events[\"timezone_offset\"].unique()","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:05:19.677911Z","iopub.execute_input":"2023-10-31T14:05:19.679127Z","iopub.status.idle":"2023-10-31T14:05:19.689739Z","shell.execute_reply.started":"2023-10-31T14:05:19.679079Z","shell.execute_reply":"2023-10-31T14:05:19.688422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/discussion/440697","metadata":{}},{"cell_type":"code","source":"print(\"=\"*80); print(\"timezone_offset == 0400\"); print(\"=\"*80); show_df(events.filter(pl.col(\"timezone_offset\")==\"-0400\"))\nprint(\"-\"*40); print(\"Unique month\"); print(\"-\"*40); print(*events.filter(pl.col(\"timezone_offset\")==\"-0400\")[\"month\"].unique()); print()\nprint(\"=\"*80); print(\"timezone_offset == 0500\"); print(\"=\"*80); show_df(events.filter(pl.col(\"timezone_offset\")==\"-0500\"))\nprint(\"-\"*40);print(\"Unique month\"); print(\"-\"*40); print(*events.filter(pl.col(\"timezone_offset\")==\"-0500\")[\"month\"].unique()); print()\nprint(\"=\"*80); print(\"timezone_offset == null\"); print(\"=\"*80); show_df(events.filter(pl.col(\"timezone_offset\").is_null()))","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:08:44.371958Z","iopub.execute_input":"2023-10-31T14:08:44.372651Z","iopub.status.idle":"2023-10-31T14:08:44.435454Z","shell.execute_reply.started":"2023-10-31T14:08:44.372601Z","shell.execute_reply":"2023-10-31T14:08:44.434253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### 3.5.2. year / month / day / hour / munite / second","metadata":{}},{"cell_type":"code","source":"# hour distribution\nfor _event in [\"wakeup\", \"onset\"]:\n    show_hist(events.filter(pl.col(\"event\")==_event), \"hour\", f\"{_event} of hour distribution\", [0,24], 24)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:19:26.117242Z","iopub.execute_input":"2023-10-31T14:19:26.117648Z","iopub.status.idle":"2023-10-31T14:19:26.778836Z","shell.execute_reply.started":"2023-10-31T14:19:26.117610Z","shell.execute_reply":"2023-10-31T14:19:26.777676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# minute distribution\nfor _event in [\"wakeup\", \"onset\"]:\n    show_hist(events.filter(pl.col(\"event\")==_event), \"minute\", f\"{_event} of hour distribution\", [0,60], 60)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:20:11.706562Z","iopub.execute_input":"2023-10-31T14:20:11.707009Z","iopub.status.idle":"2023-10-31T14:20:12.584934Z","shell.execute_reply.started":"2023-10-31T14:20:11.706977Z","shell.execute_reply":"2023-10-31T14:20:12.583255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# second distribution\nfor _event in [\"wakeup\", \"onset\"]:\n    show_hist(events.filter(pl.col(\"event\")==_event), \"second\", f\"{_event} of hour distribution\", [0,60], 60)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:20:39.714583Z","iopub.execute_input":"2023-10-31T14:20:39.715173Z","iopub.status.idle":"2023-10-31T14:20:40.669767Z","shell.execute_reply.started":"2023-10-31T14:20:39.715131Z","shell.execute_reply":"2023-10-31T14:20:40.667745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# year distribution\nfor _event in [\"wakeup\", \"onset\"]:\n    show_hist(events.filter(pl.col(\"event\")==_event), \"year\", f\"{_event} of hour distribution\", [2015,2025], 10)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:32:59.363989Z","iopub.execute_input":"2023-10-31T14:32:59.364499Z","iopub.status.idle":"2023-10-31T14:33:00.168850Z","shell.execute_reply.started":"2023-10-31T14:32:59.364465Z","shell.execute_reply":"2023-10-31T14:33:00.167721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# month distribution\nfor _event in [\"wakeup\", \"onset\"]:\n    show_hist(events.filter(pl.col(\"event\")==_event), \"month\", f\"{_event} of hour distribution\", [1,12], 12)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:21:44.620329Z","iopub.execute_input":"2023-10-31T14:21:44.620755Z","iopub.status.idle":"2023-10-31T14:21:45.454127Z","shell.execute_reply.started":"2023-10-31T14:21:44.620725Z","shell.execute_reply":"2023-10-31T14:21:45.452693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# day distribution\nfor _event in [\"wakeup\", \"onset\"]:\n    show_hist(events.filter(pl.col(\"event\")==_event), \"day\", f\"{_event} of hour distribution\", [1,12], 12)","metadata":{"execution":{"iopub.status.busy":"2023-10-31T14:22:02.652079Z","iopub.execute_input":"2023-10-31T14:22:02.652867Z","iopub.status.idle":"2023-10-31T14:22:03.568011Z","shell.execute_reply.started":"2023-10-31T14:22:02.652766Z","shell.execute_reply":"2023-10-31T14:22:03.566270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# FINISH 🏁","metadata":{}}]}