I have a table in pandas dataframe df
col1 col2 count 12 15 3 13 17 5 1 36 4 15 12 7 36 1
Sort your rows, then group and sum:
df[['a', 'b']] = df[['a', 'b']].apply(sorted, axis=1) df.groupby(['a', 'b'], as_index=False)['c'].sum()