I have two DataFrames as shown below:
data1 = {'Score1': [40,30,20], 'P1':[15.2, 13.3, 11.1], 'C1': [98,90,87]}
df1 = pd.DataFrame(data1)
df1
data2 = {'Score2': [35,33,26, 24], 'P2':[16.2, 14.7, 12.6, 11.4], 'C2': [98, 94, 86, 84]}
df2 = pd.DataFrame(data2)
df2
I would like to create a new DataFrame that contains Score1, Score2, P1, P2, C1, and C2. But P2 and C2 should be the closest value with P1 and C1, and Score2 should be ordered according to P2 and C2 order. I mean, row values should not be changed. For instance, the second row in a DataFrame 2 is Score2 = 33, P2 = 14.7 and C2 = 94. In the new data frame, this row should be the same. Also, I know row numbers are different and the new DataFrame has the row number of the DataFrame 1.
EDIT PART:
I think; the absolute value of the product of the difference of the P values and the difference of the C values should be minimum. In addition, the scores must progress by decreasing. For example, if we did not use the 2nd row and added the 3rd row to the DataFrame, we now have to continue from the 4th row for the next row.
Here is an example of expected output: