{"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":"# split + reshape ","metadata":{}},{"cell_type":"code","source":"import numpy as np ","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.435379Z","iopub.execute_input":"2021-11-12T12:39:22.435666Z","iopub.status.idle":"2021-11-12T12:39:22.440447Z","shell.execute_reply.started":"2021-11-12T12:39:22.435638Z","shell.execute_reply":"2021-11-12T12:39:22.439499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = \"1 2 3 4 5 6 7 8 9 10 11 12\"","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.442188Z","iopub.execute_input":"2021-11-12T12:39:22.442850Z","iopub.status.idle":"2021-11-12T12:39:22.454876Z","shell.execute_reply.started":"2021-11-12T12:39:22.442799Z","shell.execute_reply":"2021-11-12T12:39:22.453982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.split()","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.456745Z","iopub.execute_input":"2021-11-12T12:39:22.457672Z","iopub.status.idle":"2021-11-12T12:39:22.471117Z","shell.execute_reply.started":"2021-11-12T12:39:22.457615Z","shell.execute_reply":"2021-11-12T12:39:22.470034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(data.split())","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.472118Z","iopub.execute_input":"2021-11-12T12:39:22.472960Z","iopub.status.idle":"2021-11-12T12:39:22.486290Z","shell.execute_reply.started":"2021-11-12T12:39:22.472911Z","shell.execute_reply":"2021-11-12T12:39:22.485413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(data.split()).reshape(-1, 2)","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.488645Z","iopub.execute_input":"2021-11-12T12:39:22.489187Z","iopub.status.idle":"2021-11-12T12:39:22.501093Z","shell.execute_reply.started":"2021-11-12T12:39:22.489141Z","shell.execute_reply":"2021-11-12T12:39:22.500236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(data.split()).reshape(-1, 3)","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.502303Z","iopub.execute_input":"2021-11-12T12:39:22.502965Z","iopub.status.idle":"2021-11-12T12:39:22.514998Z","shell.execute_reply.started":"2021-11-12T12:39:22.502922Z","shell.execute_reply":"2021-11-12T12:39:22.514341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(data.split()).reshape(-1, 4)","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.516010Z","iopub.execute_input":"2021-11-12T12:39:22.516630Z","iopub.status.idle":"2021-11-12T12:39:22.527889Z","shell.execute_reply.started":"2021-11-12T12:39:22.516594Z","shell.execute_reply":"2021-11-12T12:39:22.527317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Example","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\n\nimport os \n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n%config InlineBackend.figure_formats = ['svg']","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-11-12T12:39:22.528927Z","iopub.execute_input":"2021-11-12T12:39:22.529424Z","iopub.status.idle":"2021-11-12T12:39:22.546958Z","shell.execute_reply.started":"2021-11-12T12:39:22.529389Z","shell.execute_reply":"2021-11-12T12:39:22.546383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('../input/sartorius-cell-instance-segmentation/train.csv')\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.548121Z","iopub.execute_input":"2021-11-12T12:39:22.548508Z","iopub.status.idle":"2021-11-12T12:39:22.896337Z","shell.execute_reply.started":"2021-11-12T12:39:22.548476Z","shell.execute_reply":"2021-11-12T12:39:22.895498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"annotation\"][:5]","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.897663Z","iopub.execute_input":"2021-11-12T12:39:22.898022Z","iopub.status.idle":"2021-11-12T12:39:22.905816Z","shell.execute_reply.started":"2021-11-12T12:39:22.897985Z","shell.execute_reply":"2021-11-12T12:39:22.904770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.908089Z","iopub.execute_input":"2021-11-12T12:39:22.908353Z","iopub.status.idle":"2021-11-12T12:39:22.957713Z","shell.execute_reply.started":"2021-11-12T12:39:22.908315Z","shell.execute_reply":"2021-11-12T12:39:22.957059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# split => default ,by one word","metadata":{}},{"cell_type":"code","source":"train[\"annotation\"][0].split()","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.959154Z","iopub.execute_input":"2021-11-12T12:39:22.960005Z","iopub.status.idle":"2021-11-12T12:39:22.967931Z","shell.execute_reply.started":"2021-11-12T12:39:22.959950Z","shell.execute_reply":"2021-11-12T12:39:22.967237Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# split + reshape => many rows + 2 column style ","metadata":{}},{"cell_type":"code","source":"np.array(train[\"annotation\"][0].split()).reshape(-1, 2)","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.968865Z","iopub.execute_input":"2021-11-12T12:39:22.969598Z","iopub.status.idle":"2021-11-12T12:39:22.986866Z","shell.execute_reply.started":"2021-11-12T12:39:22.969563Z","shell.execute_reply":"2021-11-12T12:39:22.986163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# convert string to int ","metadata":{}},{"cell_type":"code","source":"couples = np.array(train[\"annotation\"][0].split()).reshape(-1, 2).astype(int)\ncouples","metadata":{"execution":{"iopub.status.busy":"2021-11-12T12:39:22.987970Z","iopub.execute_input":"2021-11-12T12:39:22.988219Z","iopub.status.idle":"2021-11-12T12:39:23.006187Z","shell.execute_reply.started":"2021-11-12T12:39:22.988190Z","shell.execute_reply":"2021-11-12T12:39:23.005513Z"},"trusted":true},"execution_count":null,"outputs":[]}]}