Skip to content

Commit b6566dd

Browse files
guy-davidGuy David
and
Guy David
authored
Drop "hash" column for average merging (#256)
This is the only non-numeric column and otherwise an exception is raised. Co-authored-by: Guy David <guyda@apple.com>
1 parent 1b49285 commit b6566dd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

utils/compare.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ def readmulti(filenames):
120120
return d
121121

122122

123+
def merge_values(values, merge_function):
124+
# Drop the "hash" column because it's irreducible for averages.
125+
if merge_function is pd.DataFrame.mean and "hash" in values.columns:
126+
values = values[[c for c in values.columns if c != "hash"]]
127+
return values.groupby(level=1).apply(merge_function)
128+
129+
123130
def get_values(values):
124131
# Create data view without diff column.
125132
if "diff" in values.columns:
@@ -417,11 +424,11 @@ def main():
417424
lhs = files[0:split]
418425
rhs = files[split + 1 :]
419426

420-
# Filter minimum of lhs and rhs
427+
# Combine the multiple left and right hand sides.
421428
lhs_d = readmulti(lhs)
422-
lhs_merged = lhs_d.groupby(level=1).apply(config.merge_function)
429+
lhs_merged = merge_values(lhs_d, config.merge_function)
423430
rhs_d = readmulti(rhs)
424-
rhs_merged = rhs_d.groupby(level=1).apply(config.merge_function)
431+
rhs_merged = merge_values(rhs_d, config.merge_function)
425432

426433
# Combine to new dataframe
427434
data = pd.concat(

0 commit comments

Comments
 (0)