Download convert_to_parquet.py from xanhho/2WikiMultihopQA: direct link, hf CLI and curl.
- Browser
- Download file 537 Bytes
-
https://huggingface.co/datasets/xanhho/2WikiMultihopQA/resolve/main/convert_to_parquet.py
- Command line
-
hf download hf://datasets/xanhho/2WikiMultihopQA/convert_to_parquet.py
-
curl -L -o convert_to_parquet.py https://huggingface.co/datasets/xanhho/2WikiMultihopQA/resolve/main/convert_to_parquet.py
537 Bytes
| from pathlib import Path | |
| import pandas as pd | |
| import json | |
| file_names = ["./raw/dev.jsonl", "./raw/test.jsonl", "./raw/train.jsonl"] | |
| for file_name in file_names: | |
| df = pd.read_json(file_name, lines=True) | |
| complex_columns = [ | |
| "context", | |
| "supporting_facts", | |
| "evidences", | |
| ] | |
| for col in complex_columns: | |
| df[col] = df[col].apply(json.dumps) | |
| parquet_file_path = Path(file_name).stem + ".parquet" | |
| df.to_parquet(parquet_file_path) | |
| print(f"Converted {file_name} to {parquet_file_path}") | |