10

While this question had relative answers, I couldn't find an efficient and robust way of doing it. I have to shift the last column in my data frame to the first without disturbing any of the other columns. How should I do this ? Thanks in advance.

VishwaV
  • 379
  • 3
  • 6
  • 18

1 Answers1

14
cols = list(df.columns)
cols = [cols[-1]] + cols[:-1]
df = df[cols]
Fred
  • 403
  • 3
  • 9