This is a followup from this question.
I am trying to merge two dataframe on a common column , but one dataframe has multiple columns with same name. I want to use that column to merge.
These are my dataframes:
df1 = pd.DataFrame([['abc', 'xyz'], ['abc', 'xyz'], ['xyz', 'abc']], columns=['max_speed', 'min_speed'])
df2 = pd.DataFrame([['abc', 'xyz'], ['abc', 'xyz'], ['xyz', 'abc']], columns=['max_speed', 'max_speed'])
I have a special case where my dataframe has multiple columns with same name(reference).
I tried using the location of the column rather than name of the column to access but didnt work
What I tried:
df3 = df1.merge(df2, right_on=df1.columns[0],left_on=df2.columns[0])
Error:
ValueError: The column label 'max_speed' is not unique.
Let me know how can I solve this.