I want to swap values across specific pairs of data across rows using R or Python. I have a first dataframe containing line by line trials, and a second dataframe which is a ref