When you have a table with many columns but only want to rearrange or swap two or a few columns.
cols = list(df.columns)
a, b = cols.index('XXXX'), cols.index('YYYY')
cols[b], cols[a] = cols[a], cols[b]
df = df[cols]
Source:
https://stackoverflow.com/questions/53141240/pandas-how-to-swap-or-reorder-columns