{"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","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/hpa-processed-train-dataframe-with-cellwise-rle/train_df_w_masks_shape_bboxes.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in range(df.shape[0]):\n    a = df.loc[i,'ID']\n    f = open(f'{a}.txt', 'w')\n    b = list(set(df.loc[i, 'Label'].split('|')))\n    b_len = len(b)\n    c = df.loc[i,'bboxes'][2:-2].split('), (')\n    if c == ['']:\n        f.close()\n        continue       \n    c_len = len(df.loc[i,'bboxes'][2:-2].split('), ('))\n    for j in range(b_len):\n        for k in range(c_len):\n            d = c[k].split(', ')\n            f.write(b[j]+' '+str((float(d[0]) + float(d[2])) / 2 / df.loc[i,'dimension']) +' '+str((float(d[1]) + float(d[3])) / 2 / df.loc[i,'dimension'])+' '+str((float(d[2]) - float(d[0])) / df.loc[i,'dimension'])+' '+str((float(d[3]) - float(d[1])) / df.loc[i,'dimension'])+' ')\n            f.write('\\n')\n\n    f.close()","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}