Download src/04_merge_data.py from Desp-ML/Bioactivity_Final_Project_QM9: direct link, hf CLI and curl.
- Browser
- Download file 849 Bytes
-
https://huggingface.co/datasets/Desp-ML/Bioactivity_Final_Project_QM9/resolve/main/src/04_merge_data.py
- Command line
-
hf download hf://datasets/Desp-ML/Bioactivity_Final_Project_QM9/src/04_merge_data.py
-
curl -L -o 04_merge_data.py https://huggingface.co/datasets/Desp-ML/Bioactivity_Final_Project_QM9/resolve/main/src/04_merge_data.py
849 Bytes
| import pandas as pd | |
| import glob | |
| import os | |
| def merge_parquets(input_dir, output_file): | |
| # find all .parquet files | |
| paths = glob.glob(os.path.join(input_dir, "*.parquet")) | |
| if not paths: | |
| print(f"No parquet files found in {input_dir}") | |
| return | |
| dfs = [] | |
| for p in paths: | |
| try: | |
| df = pd.read_parquet(p) | |
| dfs.append(df) | |
| except Exception as e: | |
| print(f" ⚠️ Skipping {p}: {e}") | |
| # concat will union all columns; missing columns → NaN | |
| merged = pd.concat(dfs, ignore_index=True, sort=False) | |
| merged.to_parquet(output_file, index=False) | |
| print(f"✅ Merged {len(dfs)} files → {output_file}") | |
| print(f" Total rows: {len(merged)}, Total columns: {len(merged.columns)}") | |
| merge_parquets("./checkpoints/","./checkpoints_merged/all_data_merged.parquet") |