Skip to content

Instantly share code, notes, and snippets.

@04pallav
Created September 11, 2017 22:18
Show Gist options
  • Save 04pallav/5f892c15ab567e719c1f22d7ea461d7f to your computer and use it in GitHub Desktop.
Save 04pallav/5f892c15ab567e719c1f22d7ea461d7f to your computer and use it in GitHub Desktop.
Bring columns to front of dataframe
cols = list(df1)
cols.insert(0, cols.pop(cols.index('return_datetime'))) #3rd
cols.insert(0, cols.pop(cols.index('order_datetime'))) #2nd
cols.insert(0, cols.pop(cols.index('package_req_id'))) #1st
df1 = df1.ix[:, cols]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment