BUG: to_excel swaps order of values of duplicate columns · Issue #11007 · pandas-dev/pandas (original) (raw)
On master, as a small example:
In [1]: df = pd.DataFrame([[1,2,3,4],[5,6,7,8]], columns=['A','B','A','B'])
In [2]: df
Out[2]:
A B A B
0 1 2 3 4
1 5 6 7 8
In [4]: df.to_excel('test_excel_duplicate_columns.xlsx')
gives:
So the values of columns 2 and 3 are swapped (not the column names)
BTW, this happens both with .xlsx as .xls (openpyxl / xlsxwriter / xlwt)