Ask Your Question

Revision history [back]

subtract two data tables

ta1=[[1,1],[2,2],[3,3]] 
ta2=[[1,1],[2,1],[3,1]]

ta1_j=[]
ta2_j=[]
for i,j in ta1:
    ta1_j.append(j)
for i,j in ta2:
    ta2_j.append(j)

ta3_j=[]
for i,j in zip(ta1_j,ta2_j):
    ta3_j.append(i-j)

ta3_i=[]
for i,j in ta1:
    ta3_i.append(i)
ta3=zip(ta3_i,ta3_j)    
ta3

I want to subtract table2 from table1 in such way that X stays the same and only Y values are subtracted. The above code works for me, but is there a nicer, better and easier way to subtract tables ?