madoka_han

smallFIlesSplit

Jul 28th, 2025
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import pandas as pd
  2. from pathlib import Path
  3.  
  4. source_dir = Path("/ibex/user/harbihh/r6.2")
  5. test_dir = Path("/ibex/user/harbihh/split/r6.2")
  6. test_dir.mkdir(parents=True, exist_ok=True)
  7.  
  8. files = ["device.csv", "psychometric.csv"]
  9.  
  10. for name in files:
  11.     src = source_dir / name
  12.     dst = test_dir / name
  13.  
  14.     print(f"Processing {name}...")
  15.     df = pd.read_csv(src)
  16.     test = df.sample(frac=0.2, random_state=42)
  17.     train = df.drop(test.index)
  18.  
  19.     test.to_csv(dst, index=False)
  20.     train.to_csv(src, index=False)
  21.  
  22. print("Small file split complete.")
Advertisement
Add Comment
Please, Sign In to add comment