From e40939fc5edbec377810595626d59e61d2e2e3a5 Mon Sep 17 00:00:00 2001 From: Castorp <50649074+ShinDongWoon@users.noreply.github.com> Date: Sat, 16 Aug 2025 23:28:09 +0900 Subject: [PATCH] Handle BOM in sample columns and CSV reading --- LGHackerton/predict.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LGHackerton/predict.py b/LGHackerton/predict.py index 14733c7..a002a35 100644 --- a/LGHackerton/predict.py +++ b/LGHackerton/predict.py @@ -26,7 +26,7 @@ def _read_table(path: str) -> pd.DataFrame: if path.lower().endswith(".csv"): - return pd.read_csv(path) + return pd.read_csv(path, encoding="utf-8-sig") if path.lower().endswith((".xls", ".xlsx")): return pd.read_excel(path) raise ValueError("Unsupported file type. Use .csv or .xlsx") @@ -34,6 +34,7 @@ def _read_table(path: str) -> pd.DataFrame: def convert_to_submission(pred_df: pd.DataFrame, sample_path: str) -> pd.DataFrame: sample_df = _read_table(sample_path) + sample_df.columns = sample_df.columns.str.strip().str.lstrip('\ufeff') pred_dict = {(row.date, row.series_id): row.yhat_ens for row in pred_df.itertuples()} date_col = sample_df.columns[0] out_df = sample_df.copy()