Pandas adding `.1` suffix to column names

Viewed 562

I have an excel workbook with identically structured tables on the same sheet. I have made a loop to read them in:

for usecols in['A:L','N:Y']:
    df = pd.read_excel(r"Frequency_CI_extracted.xlsx", 
                       usecols=usecols, skiprows=3, 
                       sheet_name = 'Quantiles_CI_inches')

The resulting data frame for the first iteration (i.e. usecols="A:L") returns a data frame with the headers in the excel workbook. When the loop is on its second iteration, the resulting data frame has a .1 suffix one each column name.

enter image description here Can anyone explain this behavior?

pd.__version__
Out[9]: '1.0.3'
1 Answers

This happens when you have two identical column names in a dataframe. That's why the second iteration is adding .1

Related