-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.py
More file actions
40 lines (28 loc) · 1.02 KB
/
new.py
File metadata and controls
40 lines (28 loc) · 1.02 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
import pandas as pd
# -------- CONFIGURATION SECTION --------
files = {
"Bubble": "bubble_results.csv",
"Insertion": "insertion_results.csv",
"Selection": "selection_results.csv",
"Merge": "merge_results.csv",
"Heap": "heap_results.csv",
"Quick": "quick_results.csv"
}
# Column you want to extract (change later if needed)
column_to_extract = "Comparisons"
output_file = "compiled_side_by_sides.csv"
# ---------------------------------------
# Read first file completely
first_algo = list(files.keys())[0]
base_df = pd.read_csv(files[first_algo])
# Keep common columns
final_df = base_df[["Array_No", "Type", "Size"]].copy()
# Add first algorithm comparison column
final_df[first_algo] = base_df[column_to_extract]
# Process remaining files
for algo in list(files.keys())[1:]:
df = pd.read_csv(files[algo])
final_df[algo] = df[column_to_extract]
# Save new CSV
final_df.to_csv(output_file, index=False)
print("Compiled CSV created successfully:", output_file)