{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":22990,"datasetId":1136396,"databundleVersionId":2048213},{"sourceType":"datasetVersion","sourceId":16226508,"datasetId":10392448,"databundleVersionId":17207884}],"dockerImageVersionId":31328,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\n\n# --------------------- 路径你不用改 ---------------------\nINPUT_CSV = \"/kaggle/input/datasets/linplusx/hub-sub1/submission.csv\"\nSAMPLE_CSV = \"/kaggle/input/competitions/hubmap-kidney-segmentation/sample_submission.csv\"\nOUTPUT_CSV = \"/kaggle/working/submission.csv\"\n\n# 1. 读取官方模板（最重要！必须用它的 ID 和顺序）\nsample = pd.read_csv(SAMPLE_CSV)\n\n# 2. 读取你已经生成的结果\ndf_pred = pd.read_csv(INPUT_CSV)\n\n# 3. 强制统一列名（不管你原来是什么，都改成正确格式）\ndf_pred.columns = [\"id\", \"predicted\"]\n\n# 4. 把你的预测 匹配到官方 ID 顺序\nsub = sample.copy()\nsub[\"predicted\"] = sub[\"id\"].map(df_pred.set_index(\"id\")[\"predicted\"])\n\n# 5. 空值填为空字符串（避免提交失败）\nsub[\"predicted\"] = sub[\"predicted\"].fillna(\"\")\nsub.iloc[-3:, 1] = \"\"\n\n\n# 6. 保存最终可提交文件\nsub.to_csv(OUTPUT_CSV, index=False)\n\n# --------------------- 输出确认 ---------------------\nprint(\"✅ 正确提交文件已生成！\")\nprint(\"📄 列名：\", sub.columns.tolist())\nprint(\"📊 形状：\", sub.shape)\nprint(\"\\n预览：\")\nprint(sub.head())","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-05-13T05:35:29.835050Z","iopub.execute_input":"2026-05-13T05:35:29.835388Z","iopub.status.idle":"2026-05-13T05:35:30.518250Z","shell.execute_reply.started":"2026-05-13T05:35:29.835358Z","shell.execute_reply":"2026-05-13T05:35:30.517386Z"}},"outputs":[],"execution_count":null}]}