Lets say I have the following data set:
import numpy as np
import pandas as pd
d = {'column1': ['a', 'b', 'c'], 'a': [10, 8, 6], 'a1': [1, 2, 3], 'b': [4, 2, 6], 'b1': [1, 4, 8], 'c': [2, 6, 8], 'c1': [2, 1, 8] }
data_frame = pd.DataFrame(data=d).set_index('column1')
What I want to achieve is following. Sum each row values, excluding the observations where a=a, a=a1, b=b, b=b1, and so on.
So in the final dataset I want to have something like this:
f={'total': [9, 17, 23]}
final_frame = pd.DataFrame(data=f)
Where 9 = b + b1 + c + c1 and so on.
Obvisuly, I can achieve this by iloc[] command on every row. But my real dataframe is quite huge, and as you can see the position of ij elements which need to be dropped are not constant across the rows (so every iloc on each row will be different, but consistent sequence).
Any suggestions?
Best,