DECROMAX

Move column to specified index (position)

Sep 22nd, 2022
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.17 KB | None | 0 0
  1.     """Moves column to specified index"""
  2.    
  3.     col = df.pop("col_name")
  4.     df.insert(0, col.name, col) # change 0 to other position if required (0 = first column)
Advertisement
Add Comment
Please, Sign In to add comment