{"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":"import pandas as pd\nimport matplotlib.pyplot as plt\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-09-09T11:26:31.987303Z","iopub.execute_input":"2023-09-09T11:26:31.987762Z","iopub.status.idle":"2023-09-09T11:26:32.397759Z","shell.execute_reply.started":"2023-09-09T11:26:31.987720Z","shell.execute_reply":"2023-09-09T11:26:32.396329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 1 - import","metadata":{}},{"cell_type":"code","source":"print('import datas...')\ntrain_series = pd.read_parquet('/kaggle/input/child-mind-institute-detect-sleep-states/train_series.parquet')\ntest_series = pd.read_parquet('/kaggle/input/child-mind-institute-detect-sleep-states/test_series.parquet')\ntrain_events = pd.read_csv('/kaggle/input/child-mind-institute-detect-sleep-states/train_events.csv')\nsample_submission = pd.read_csv('/kaggle/input/child-mind-institute-detect-sleep-states/sample_submission.csv')\nprint('Done')","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:26:32.400402Z","iopub.execute_input":"2023-09-09T11:26:32.400891Z","iopub.status.idle":"2023-09-09T11:27:31.798719Z","shell.execute_reply.started":"2023-09-09T11:26:32.400860Z","shell.execute_reply":"2023-09-09T11:27:31.797237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 2 - view data","metadata":{}},{"cell_type":"code","source":"train_series","metadata":{"execution":{"iopub.status.busy":"2023-09-09T11:27:31.800307Z","iopub.execute_input":"2023-09-09T11:27:31.801488Z","iopub.status.idle":"2023-09-09T11:27:31.827424Z","shell.execute_reply.started":"2023-09-09T11:27:31.801451Z","shell.execute_reply":"2023-09-09T11:27:31.826218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_series","metadata":{"execution":{"iopub.status.busy":"2023-09-09T11:27:31.830584Z","iopub.execute_input":"2023-09-09T11:27:31.831721Z","iopub.status.idle":"2023-09-09T11:27:31.850343Z","shell.execute_reply.started":"2023-09-09T11:27:31.831414Z","shell.execute_reply":"2023-09-09T11:27:31.848663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_events","metadata":{"execution":{"iopub.status.busy":"2023-09-09T11:27:31.851771Z","iopub.execute_input":"2023-09-09T11:27:31.852077Z","iopub.status.idle":"2023-09-09T11:27:31.874577Z","shell.execute_reply.started":"2023-09-09T11:27:31.852052Z","shell.execute_reply":"2023-09-09T11:27:31.873788Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission","metadata":{"execution":{"iopub.status.busy":"2023-09-09T11:27:31.875979Z","iopub.execute_input":"2023-09-09T11:27:31.877076Z","iopub.status.idle":"2023-09-09T11:27:31.887456Z","shell.execute_reply.started":"2023-09-09T11:27:31.877045Z","shell.execute_reply":"2023-09-09T11:27:31.886677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 3 - data size, type, missing values, unique values","metadata":{}},{"cell_type":"code","source":"print('** train_series shape **')\nprint(train_series.shape)\nprint('**************')\nprint('** test_series shape **')\nprint(test_series.shape)\nprint('**************')\nprint('** train_events shape **')\nprint(train_events.shape)\nprint('**************')\n","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:31.888486Z","iopub.execute_input":"2023-09-09T11:27:31.889111Z","iopub.status.idle":"2023-09-09T11:27:31.904863Z","shell.execute_reply.started":"2023-09-09T11:27:31.889076Z","shell.execute_reply":"2023-09-09T11:27:31.904125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('** train_series dtypes **')\nprint(train_series.dtypes)\nprint('**************')\nprint('** test_series dtypes **')\nprint(test_series.dtypes)\nprint('**************')\nprint('** train_events dtypes **')\nprint(train_events.dtypes)\nprint('**************')","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:31.906387Z","iopub.execute_input":"2023-09-09T11:27:31.906896Z","iopub.status.idle":"2023-09-09T11:27:31.928397Z","shell.execute_reply.started":"2023-09-09T11:27:31.906868Z","shell.execute_reply":"2023-09-09T11:27:31.925305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Define original function: missing_value')\n\ndef missing_value(data):\n    total = data.isnull().sum().sort_values(ascending = False)\n    percent = (data.isnull().sum()/data.isnull().count()*100).sort_values(ascending = False)\n    return pd.concat([total, percent], axis=1, keys=['Total', 'Percent'])","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:31.930590Z","iopub.execute_input":"2023-09-09T11:27:31.930996Z","iopub.status.idle":"2023-09-09T11:27:31.948147Z","shell.execute_reply.started":"2023-09-09T11:27:31.930959Z","shell.execute_reply":"2023-09-09T11:27:31.947079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('The number and percentage of missing values: train_series')\nmissing_value(train_series).style.set_properties(**{'background-color': 'rgba(245, 181, 152,.5)'})","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:31.952797Z","iopub.execute_input":"2023-09-09T11:27:31.953961Z","iopub.status.idle":"2023-09-09T11:27:55.148599Z","shell.execute_reply.started":"2023-09-09T11:27:31.953927Z","shell.execute_reply":"2023-09-09T11:27:55.146789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('The number and percentage of missing values: test_series')\nmissing_value(test_series).style.set_properties(**{'background-color': 'rgba(245, 181, 152,.5)'})","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:55.149932Z","iopub.execute_input":"2023-09-09T11:27:55.150628Z","iopub.status.idle":"2023-09-09T11:27:55.166830Z","shell.execute_reply.started":"2023-09-09T11:27:55.150593Z","shell.execute_reply":"2023-09-09T11:27:55.165626Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('The number and percentage of missing values: train_events')\nmissing_value(train_events).style.set_properties(**{'background-color': 'rgba(245, 181, 152,.5)'})","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:55.168139Z","iopub.execute_input":"2023-09-09T11:27:55.168740Z","iopub.status.idle":"2023-09-09T11:27:55.196023Z","shell.execute_reply.started":"2023-09-09T11:27:55.168713Z","shell.execute_reply":"2023-09-09T11:27:55.194781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Define original function: create_uniqueInfo_List')\n\ndef num_unique_list(data):\n    num_uniques = []\n    for c in data.columns:\n        n_unique = data[c].nunique()\n        num_uniques.append(n_unique)\n    return num_uniques\n\ndef create_uniqueInfo_List(data):\n    uList = pd.DataFrame(data.count())\n    uList.columns = ['Num of Values']\n    uList['Valiations'] = num_unique_list(data)\n\n    a_uniques = []\n    only_one = []\n    for row in uList.itertuples(name=None):\n        if row[1] == row[2]:\n            a_uniques.append('*')\n        else:\n            a_uniques.append('')\n        if row[2] == 1:\n            only_one.append('*')\n        else:\n            only_one.append('')\n\n    uList['ALL_Unique ?'] = a_uniques\n    uList['Only_one_value ?'] = only_one\n\n    return uList","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:27:55.197576Z","iopub.execute_input":"2023-09-09T11:27:55.197994Z","iopub.status.idle":"2023-09-09T11:27:55.207129Z","shell.execute_reply.started":"2023-09-09T11:27:55.197962Z","shell.execute_reply":"2023-09-09T11:27:55.206198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Number of unique data: train_series')\ncreate_uniqueInfo_List(train_series).style.set_properties(**{'background-color': 'rgba(145, 178, 227,.5)'})","metadata":{"execution":{"iopub.status.busy":"2023-09-09T11:27:55.208328Z","iopub.execute_input":"2023-09-09T11:27:55.208623Z","iopub.status.idle":"2023-09-09T11:29:09.613376Z","shell.execute_reply.started":"2023-09-09T11:27:55.208601Z","shell.execute_reply":"2023-09-09T11:29:09.611770Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Number of unique data: test_series')\ncreate_uniqueInfo_List(test_series).style.set_properties(**{'background-color': 'rgba(145, 178, 227,.5)'})","metadata":{"jupyter":{"source_hidden":true},"execution":{"iopub.status.busy":"2023-09-09T11:29:09.616092Z","iopub.execute_input":"2023-09-09T11:29:09.617105Z","iopub.status.idle":"2023-09-09T11:29:09.631502Z","shell.execute_reply.started":"2023-09-09T11:29:09.617073Z","shell.execute_reply":"2023-09-09T11:29:09.630417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Number of unique data: train_events')\ncreate_uniqueInfo_List(train_events).style.set_properties(**{'background-color': 'rgba(145, 178, 227,.5)'})","metadata":{"execution":{"iopub.status.busy":"2023-09-09T11:29:09.633142Z","iopub.execute_input":"2023-09-09T11:29:09.633803Z","iopub.status.idle":"2023-09-09T11:29:09.666412Z","shell.execute_reply.started":"2023-09-09T11:29:09.633741Z","shell.execute_reply":"2023-09-09T11:29:09.664859Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"updating now.....","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"}}