Skip to content

BUG: concatenation is allowing duplicate columns when axis=1 #60504

@Sakethsreeram7

Description

@Sakethsreeram7

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df1=pd.DataFrame({'a':1,'b':2},index=[0])
df2=pd.DataFrame({'a':1,'b':2},index=[0])
df_new=pd.concat([df1,df2],axis=1)

Issue Description

When concatenation is done by axis=1 the duplicate columns are added up without raising an error then this will be very confusing as these are not identified as different

Expected Behavior

If the columns are the same before concatenating then in new df these should be some unique identifier
let's say: a(1), b(1) like this

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions