Spaces:
Build error
Build error
| #!/usr/bin/env python | |
| import sys | |
| import pandas as pd | |
| df = pd.read_csv(sys.argv[1]) | |
| df = df[df["ID"].notna()] | |
| assert isinstance(df, pd.DataFrame), "Narrowing down the type of df" | |
| df["id"] = df["ID"].apply(lambda x: f"id:govsearch:qa::{x}") | |
| df["fields"] = df.apply( | |
| lambda row: { | |
| "doc_id": row["ID"], | |
| "category_major": row["ε€§ει‘"], | |
| "category_medium": row["δΈει‘"], | |
| "category_minor": row["ε°ει‘"], | |
| "question": row["εγ"], | |
| "answer": row["εη"], | |
| }, | |
| axis=1, | |
| ) | |
| print(df[["id", "fields"]].to_json(orient="records", force_ascii=False, lines=True)) | |