Rename columns that are exactly same

22 views Asked by At

I have an Excel file with two columns "Super Type". I've imported this Excel file into a DataFrame without directly opening it due to its large size. However, now that it's in my DataFrame, I've encountered a problem because both columns have the exact same name. What steps should I take to address this issue? The rename techniques did not help me.

I did this :

duplicate_columns = df.columns[df.columns.duplicated(keep=False)]
for col in duplicate_columns:
  df.rename(columns={col: col + "_2"}, inplace=True)

but after that, I again had two columns the with same name.

0

There are 0 answers