I should join 2 pandas DataFrames with partially overlapping column names: Col1
,Col2
. The other columns do not overlap.
I get the following error:
ValueError: Indexes have overlapping values: Index(['Col1','Col2']
Joining is done as follows:
df1.join([df2], how='inner')
Of course, I can manually drop Col1
and Col2
from one of DataFrames. But I wonder if there is a better solution. I am using pandas version 0.25
.
I am searching for something like this (or other option that would allow avoiding the manual dropping of columns):
df1.join([df2], how='inner', take_overlapping_columns_from_left=True)
Is it possible to do or should I proceed with the columns dropping solution?