{"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":"code","source":"import pandas as pd\n\npd.set_option('display.max_columns', 30)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-25T05:38:21.047967Z","iopub.execute_input":"2023-10-25T05:38:21.048468Z","iopub.status.idle":"2023-10-25T05:38:21.502471Z","shell.execute_reply.started":"2023-10-25T05:38:21.048396Z","shell.execute_reply":"2023-10-25T05:38:21.501068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"de_train = pd.read_parquet('/kaggle/input/open-problems-single-cell-perturbations/de_train.parquet')\n\nprint(de_train.shape)\nde_train.head(2)","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:21.504437Z","iopub.execute_input":"2023-10-25T05:38:21.505015Z","iopub.status.idle":"2023-10-25T05:38:24.439062Z","shell.execute_reply.started":"2023-10-25T05:38:21.504960Z","shell.execute_reply":"2023-10-25T05:38:24.437610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"is_mean = False\nis_median = False\nis_quantile = True","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:24.440695Z","iopub.execute_input":"2023-10-25T05:38:24.442249Z","iopub.status.idle":"2023-10-25T05:38:24.447164Z","shell.execute_reply.started":"2023-10-25T05:38:24.442199Z","shell.execute_reply":"2023-10-25T05:38:24.446245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"groupby_sm_name = de_train[['sm_name'] + list(de_train.columns[5:])].groupby('sm_name')\n\nif is_mean:\n    sm_name_stats = groupby_sm_name.mean()\nelif is_median:\n    sm_name_stats = groupby_sm_name.median()\nelif is_quantile:\n    sm_name_stats = groupby_sm_name.quantile(0.6)\n    \nsm_name_stats","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:24.449852Z","iopub.execute_input":"2023-10-25T05:38:24.450574Z","iopub.status.idle":"2023-10-25T05:38:26.410984Z","shell.execute_reply.started":"2023-10-25T05:38:24.450542Z","shell.execute_reply":"2023-10-25T05:38:26.409738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = pd.read_csv('/kaggle/input/open-problems-single-cell-perturbations/sample_submission.csv', index_col=0)\nsample_submission","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:26.412268Z","iopub.execute_input":"2023-10-25T05:38:26.413111Z","iopub.status.idle":"2023-10-25T05:38:31.348420Z","shell.execute_reply.started":"2023-10-25T05:38:26.413080Z","shell.execute_reply":"2023-10-25T05:38:31.346905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"id_map = pd.read_csv('/kaggle/input/open-problems-single-cell-perturbations/id_map.csv')\nid_map","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:31.350567Z","iopub.execute_input":"2023-10-25T05:38:31.351498Z","iopub.status.idle":"2023-10-25T05:38:31.374143Z","shell.execute_reply.started":"2023-10-25T05:38:31.351455Z","shell.execute_reply":"2023-10-25T05:38:31.372889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = id_map.merge(sm_name_stats, how='left', on='sm_name')\nsample_submission = sample_submission.set_index('id').iloc[:, 2:]\n\nsample_submission","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:31.376093Z","iopub.execute_input":"2023-10-25T05:38:31.376483Z","iopub.status.idle":"2023-10-25T05:38:31.553561Z","shell.execute_reply.started":"2023-10-25T05:38:31.376452Z","shell.execute_reply":"2023-10-25T05:38:31.552311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.to_csv('submission.csv')\n\npd.read_csv('/kaggle/working/submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-10-25T05:38:31.555495Z","iopub.execute_input":"2023-10-25T05:38:31.556239Z","iopub.status.idle":"2023-10-25T05:38:49.981589Z","shell.execute_reply.started":"2023-10-25T05:38:31.556195Z","shell.execute_reply":"2023-10-25T05:38:49.980445Z"},"trusted":true},"execution_count":null,"outputs":[]}]}