Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LGHackerton/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

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")


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()
Expand Down