I have a df1
Date Open Expiry Entry Strike
0 2020-01-03 12261.10 2020-01-09 12200.0
1 2020-01-10 12271.00 2020-01-16 12200.0
2 2020-01-17 12328.40 2020-01-23 12300.0
3 2020-01-24 12174.55 2020-01-30 12100.0
4 2020-01-31 12100.40 2020-02-06 12100.0
i want to add values from df2
Date Expiry Type Strike Price Open Close
0 2020-01-03 2020-01-09 CE 13100 0.0 65.85
1 2020-01-03 2020-01-09 CE 13150 0.0 59.40
2 2020-01-03 2020-01-09 CE 13200 0.0 53.55
3 2020-01-03 2020-01-09 CE 13250 0.0 48.15
4 2020-01-03 2020-01-09 CE 13300 0.0 43.25
i want to compare elements of column Date , Expiry and Entry Price with Date ,Expiry and Strike Price of df2 and add corresponding Open column element to df1 if the condition matches. when i directly compare columns i get errors like .
ValueError: Can only compare identically-labeled Series objects
thanks for the help
df1["Entry CE"] = df2["Open"] if (df1['Date'] == df2['Date']) & (df1['Expiry'] == df2['Expiry'])& (df1['Entry Strike'] == df2['Strike Price']) else " "i tried this . i dont know if its the correct way. i am new to pandas .