df_a and df_b are two dataframes that looks like following. They do NOT have same length.
--> df_a
col_1 col_2
a b
c
d
e
f g
--> df_b
col_3
a
c
d
e
I know I can achieve a merge with AND clause with :
df_a = pd.Dataframe({"col_1": ["a", "c", "d", None, "f"], "col_2": ["b", None, None, "e", "g"]})
df_b = pd.Dataframe({"col_3": ["a", "c", "d", "e"]})
pd.merge(df_a, df_b, how="inner", left_on=["col_1", "col_2"], right_on=["col_3", "col_3"])
My need is to merged them based on a OR clause like col_1 == col_3 OR col_2 == col_3. Ideally I do not want to make two merges separately.
Appreciate any suggestions.