Skip to content

concatenated DataFrames with duplicated columns cannot be printed #1675

@ruidc

Description

@ruidc

In the following, the concatenation happens, columns c and d are duplicated, but printing the dataframe raises error:

import pandas
df1 = pandas.DataFrame([[1,2], [3,4]], columns=['a','b'], index=[1,2])
df2 = pandas.DataFrame([[1,2], [3,4]], columns=['c','d'], index=[1,2])
df_all = pandas.concat([df1, df2], axis=1)
print(df_all)
df4 = pandas.DataFrame([[1,2], [3,4]], columns=['a','b'], index=[3,4])
df_all = pandas.concat([df_all, df4], axis=0)
print(df_all)
df5 = pandas.DataFrame([[1,2], [3,4]], columns=['c','d'], index=[3,4])
df_all = pandas.concat([df_all, df5], axis=1)
print(df_all)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions