{"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"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":53666,"databundleVersionId":6589269,"sourceType":"competition"}],"dockerImageVersionId":30558,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-11-17T13:04:15.312691Z","iopub.execute_input":"2023-11-17T13:04:15.312998Z","iopub.status.idle":"2023-11-17T13:04:17.316987Z","shell.execute_reply.started":"2023-11-17T13:04:15.312976Z","shell.execute_reply":"2023-11-17T13:04:17.315666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_parquet(\"/kaggle/input/child-mind-institute-detect-sleep-states/test_series.parquet\")\nonset = test[test[\"timestamp\"].str.slice(11,19)==\"23:00:00\"].set_index(\"series_id\")[\"step\"]\nwakeup = test[test[\"timestamp\"].str.slice(11,19)==\"06:30:00\"].set_index(\"series_id\")[\"step\"]","metadata":{"execution":{"iopub.status.busy":"2023-11-17T13:05:54.988198Z","iopub.execute_input":"2023-11-17T13:05:54.988571Z","iopub.status.idle":"2023-11-17T13:05:55.004416Z","shell.execute_reply.started":"2023-11-17T13:05:54.988530Z","shell.execute_reply":"2023-11-17T13:05:55.003026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.concat([\n    onset.reset_index().assign(event=\"onset\"),\n    wakeup.reset_index().assign(event=\"wakeup\"),\n])\nsub[\"score\"] = 0.5\nsub.sort_values([\"series_id\",\"event\"], ascending=[0,1], inplace=True)\nsub.reset_index(drop=True, inplace=True)\nsub[\"row_id\"] = sub.index\nsub = sub[[\"row_id\",\"series_id\",\"step\",\"event\",\"score\"]]\nsub.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2023-11-17T13:05:56.845893Z","iopub.execute_input":"2023-11-17T13:05:56.846911Z","iopub.status.idle":"2023-11-17T13:05:56.861215Z","shell.execute_reply.started":"2023-11-17T13:05:56.846848Z","shell.execute_reply":"2023-11-17T13:05:56.860027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}