reorder column numbers using column index pandas code example
Example 1: how to change the column order in pandas dataframe
df = df.reindex(columns=column_names)
Example 2: reorder columns pandas
cols = df.columns.tolist()
# Rearrange the list any way you want
cols = cols[-1:] + cols[:-1]
df = df[cols]