Skip to content

Commit

Permalink
#937 Added option to change the name of the average row
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelgitgomes committed May 3, 2024
1 parent f147c0e commit b405c84
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions atom_batch_execution/scripts/process_results
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ from atom_core.utilities import atomWarn, removeColorsFromText
import pandas as pd


def averageCsvFiles(filenames):
def averageCsvFiles(filenames, average_row):

# Get a list of the pandas representation of the csvs
pandas_text_df = pd.read_csv(filenames[0])
Expand All @@ -32,7 +32,7 @@ def averageCsvFiles(filenames):
df = pd.read_csv(filename)

# Filter all cells for averages
df = df[df['Collection #'].isin(['Averages'])]
df = df[df['Collection #'].isin([average_row])]

df = df.apply(pd.to_numeric, errors="coerce")
pandas_dfs.append(df)
Expand Down Expand Up @@ -60,6 +60,8 @@ def main():
required=False, default='_run', type=str)
ap.add_argument("-fs", "--fold_suffix", help="Suffix used to signal multiple folds of the same run.",
required=False, default='_fold', type=str)
ap.add_argument("-ar", "--average_row", help="Name of the row to average. Default is 'Averages'",
required=False, default='Averages', type=str)

args = vars(ap.parse_args())

Expand All @@ -71,6 +73,8 @@ def main():
# bprint('Overwriting output folder: ' + config['output_folder'])
shutil.rmtree(args['output_folder']) # Create the new folder
os.mkdir(args['output_folder']) # Create the new folder

print('Average row: ' + args['average_row'])

# We need to get the experiments from the set of folders (runs) in the results_folder. An experiment is a set of one or more runs, with filenames <experiment_name>_r1

Expand Down Expand Up @@ -113,7 +117,7 @@ def main():

filenames = [run + '/' + file_to_process for run in files_and_folders]

average_df = averageCsvFiles(filenames)
average_df = averageCsvFiles(filenames, args['average_row'])

average_df = average_df.drop(columns=['Collection #'])

Expand Down

0 comments on commit b405c84

Please sign in to comment.