Pandas - move last df column to front

PHOTO EMBED

Sun Mar 19 2023 22:06:55 GMT+0000 (Coordinated Universal Time)

Saved by @sfull #python

# get the column names and move the last column to the front
cols = list(df.columns)
cols = [cols[-1]] + cols[:-1]

# reindex the dataframe with the new column order
df = df.reindex(columns=cols)
content_copyCOPY