I have two different datasets a and b. I want to left join b to a but I want to join to a where only left join b['ColA'] and b['ColC'] to matching a['ColA'] and a['ColC']==1
something like expected_table = pd.merge(a,b, left_on=['ColA', ['ColC']==1 ] ,rigth_on = ['ColA',['ColC']==0])
a = pd.DataFrame({"ColA":["num 1", "num 2", "num 3"],
"ColB":[5,6,7],
"ColC":[1,1,0]})
b = pd.DataFrame({"ColA":["num 1", "num 2", "num 4"],
"Colx":[10,16,71],
"Coly":[0,0,0]})
Coly is all equal 0
expected= pd.DataFrame({"ColA":["num 1", "num 2", "num 3"],
"ColB":[5,6,7],
"ColC":[1,1,0],
"Colx":[10,16,None]})```
I solve it by creating a new column on b table that matches same value with a['colx'].
But I wonder if there is a way to let you use conditions in merge/join process like in sql.