forked from EC527JilinZhengVarshaSingh/super-raytrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
40 lines (32 loc) · 1.48 KB
/
Copy pathprocess.py
File metadata and controls
40 lines (32 loc) · 1.48 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
# Define the input and output file names
input_filenames= [
'250427_gpu_global_float_timing_100sample.csv',
'250427_gpu_const_float_timing_100sample.csv',
'250427_gpu_tex_float_timing_100sample.csv'
]
output_filenames = [
'250427_avg_gpu_global_float_timing_100sample.csv',
'250427_avg_gpu_const_float_timing_100sample.csv',
'250427_avg_gpu_tex_float_timing_`100sample.csv'
]
# Define the columns to group by
group_cols = ['scene_id', 'width', 'height', 'samples', 'bounces', 'threads']
for i in range(len(input_filenames)):
try:
# Read the CSV data into a pandas DataFrame
df = pd.read_csv(input_filenames[i])
# Group by the specified columns and calculate the mean of the time columns
averaged_data = df.groupby(group_cols)[['render_only_time_ms', 'end_to_end_time_ms']].mean().reset_index()
# Rename the average columns
averaged_data = averaged_data.rename(columns={
'render_only_time_ms': 'avg_render_only_time_ms',
'end_to_end_time_ms': 'avg_end_to_end_time_ms'
})
# Save the new DataFrame to a new CSV file
averaged_data.to_csv(output_filenames[i], index=False)
print(f"Averaged data saved to '{output_filenames[i]}'")
except FileNotFoundError:
print(f"Error: Input file '{input_filenames[i]}' not found. Make sure the CSV file is in the same directory as the script.")
except Exception as e:
print(f"An error occurred: {e}")