I was trying to do a code and got stucked in here.Having a data frame as below:
data = {'Name1':['A', 'B', 'C', 'D','E','F','G','H'],'Name2':['B','C','D','E','F','G','H','D'],
'sum':[12,10,5,5, 10,15,10,13]
}
df = pd.DataFrame(data)
df
Have a list of elements as follows:
my_list=[[A,B],[F,G],[A,B,C],[A,B,C,D,E],[E,F,G]]
Need to find out the sum as follows:
[A,B]->12
[F,G]->15
[A,B,C]->[A,B]+[B,C]->12+10=22
[A,B,C,D,E]->[A,B]+[B,C]+[C,D]+[D,E]->12+10+5+5=32
[E,F,G]->[E,F]+[F,G]->10+15=25