{"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\nimport numpy as np\nfrom sklearn.model_selection import GroupKFold","metadata":{"execution":{"iopub.status.busy":"2021-07-14T20:36:23.856157Z","iopub.execute_input":"2021-07-14T20:36:23.856719Z","iopub.status.idle":"2021-07-14T20:36:23.861634Z","shell.execute_reply.started":"2021-07-14T20:36:23.856673Z","shell.execute_reply":"2021-07-14T20:36:23.860384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train_labels.csv')\ngkf  = GroupKFold(n_splits = folds)\ndf['fold'] = -1\nfor fold, (train_idx, val_idx) in enumerate(gkf.split(df, groups = df.BraTS21ID.tolist())):\n    df.loc[val_idx, 'fold'] = fold","metadata":{"execution":{"iopub.status.busy":"2021-07-14T20:15:05.134835Z","iopub.execute_input":"2021-07-14T20:15:05.135234Z","iopub.status.idle":"2021-07-14T20:15:05.153110Z","shell.execute_reply.started":"2021-07-14T20:15:05.135197Z","shell.execute_reply":"2021-07-14T20:15:05.152307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for index, item in enumerate(df.BraTS21ID):\n    n = item\n    df.loc[index, \"folder_name\"] = (5 - len([i for i in str(n)])) * \"0\" + str(n)","metadata":{"execution":{"iopub.status.busy":"2021-07-14T20:35:24.371090Z","iopub.execute_input":"2021-07-14T20:35:24.371478Z","iopub.status.idle":"2021-07-14T20:35:24.518377Z","shell.execute_reply.started":"2021-07-14T20:35:24.371447Z","shell.execute_reply":"2021-07-14T20:35:24.517414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"execution":{"iopub.status.busy":"2021-07-14T20:35:26.284221Z","iopub.execute_input":"2021-07-14T20:35:26.284559Z","iopub.status.idle":"2021-07-14T20:35:26.300637Z","shell.execute_reply.started":"2021-07-14T20:35:26.284529Z","shell.execute_reply":"2021-07-14T20:35:26.299499Z"},"trusted":true},"execution_count":null,"outputs":[]}]}