File size: 921 Bytes
f1d4767
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas as pd
import os

# Load the data
metadata = pd.read_csv("gaps_metadata.csv")
splits = pd.read_csv("gaps_split_data.csv")

# Extract path stems from the splits data (filename without extension)
splits['path_stem'] = splits['path'].apply(lambda x: os.path.splitext(os.path.basename(x))[0])

# Merge the splits information with the metadata based on scorehash = path_stem
merged_metadata = metadata.merge(
    splits[['path_stem', 'split']], 
    left_on='scorehash', 
    right_on='path_stem', 
    how='left'
)

# Drop the temporary path_stem column
merged_metadata = merged_metadata.drop('path_stem', axis=1)

# Save the updated metadata to a new CSV file
merged_metadata.to_csv("gaps_metadata_with_splits.csv", index=False)

print(f"Merged metadata saved to gaps_metadata_with_splits.csv")
print(f"Added split information to {merged_metadata['split'].notna().sum()} out of {len(merged_metadata)} records")