I have two data frames.
df1 = pd.DataFrame({'Ver' : [2,2,2],
'SN' : [1,1,1],
'Split' : [AA,AA,AA]
'Quad' : [3,3,4]
'Channel' : [1,2,0]
'Mean' : [1,2,3]
'Other' : [10,10,10]
'Mean2' : [1,2,3]
'Other2' : [10,10,10]
})
df1 = pd.DataFrame({'Ver' : [2,2,2],
'SN' : [1,1,1],
'Split' : [AA,AA,AA]
'Quad' : [3,3,4]
'Channel' : [3,2,0]
'Mean' : [4,5,6]
'Other' : [10,10,10]
'Mean2' : [4,5,6]
'Other2' : [10,10,10]
})
i'd like to subtract the mean column in df1 from the mean column in df2 and do this only for elements whose values match in columns 'SN', 'Quad', 'Channel'. if those values don't match up, i'd like to "throw out" the data. I'd like to do the same for the mean2 column. i'd like assign the resultant data frame to a new dataframe. is there an easy/straightforward way to do this in pandas?
i should end up with :
resultant_df= pd.DataFrame({'Ver' : [2,2],
'SN' : [1,1],
'Split' : [AA,AA]
'Quad' : [3,4]
'Channel' : [2,0]
'Mean' : [-3,-3]
'Other' : [,10,10]
'Mean2' : [-3,-3]
'Other2' : [10,10]
})