Skip to content

Commit bd5a44f

Browse files
author
Luigi Dello Stritto
committed
fix to processer.py
1 parent 9198345 commit bd5a44f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

machine_learning_hep/processer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,12 @@ def dfuse(df_spec):
423423
self.logger.info('exploding dataframe %s on variable %s', base, on)
424424
dfs[base] = dfs[base].explode(on)
425425
dfs[out] = dfmerge(dfs[base], dfs[ref], left_on=['df', on], right_index=True)
426-
dfs[out].index.name = 'MergedIndex'
427-
dfs[out] = dfs[out].reset_index()
428-
sorted_df = dfs[out].sort_values('fMultZeqNTracksPV', ascending=False)
429-
dfs[out] = sorted_df.drop_duplicates('MergedIndex')
430-
dfs[out] = dfs[out].sort_values('MergedIndex', ascending=True)
426+
if not is_numeric_dtype(dfs[base][on]):
427+
dfs[out].index.name = 'MergedIndex'
428+
dfs[out] = dfs[out].reset_index()
429+
sorted_df = dfs[out].sort_values('fMultZeqNTracksPV', ascending=False)
430+
dfs[out] = sorted_df.drop_duplicates('MergedIndex')
431+
dfs[out] = dfs[out].sort_values('MergedIndex', ascending=True)
431432
else:
432433
var = self.df_read[ref]['index']
433434
self.logger.info('merging %s with %s on %s (default) into %s', base, ref, var, out)

0 commit comments

Comments
 (0)