I have a sample dataframe like this:
data = {'From': ['1', '1', '2', '2'],
'To': ['2', '4', '1', '7'],
'Total': [100, 100, 100, 100]
}
dataf = pd.DataFrame(data, columns = ['From', 'To', 'Total'])
Which looks like this:
The first and third row are duplicated, but just in a different order i.e. (1,2) and (2,1).
I want to remove the duplicated rows, but sum the values onto which ever row is left.
i.e. the table would look like this:
I have found posts that discuss how to remove duplications that are in any column order (eg. Grouping by multiple columns to find duplicate rows pandas), but nothing about how to sum the values before removing.