2019 June 7thRe-arranging Columns in your Dataframepandas
How to re-arrange the columns in your Dataframe
- Print out the column labels of your Dataframe
print(df.columns())
- Copy the printed list and re-arrange as you like. Store it in a var
foo
. For example, my columns are:['shipper_id',``_shipper' 'period']
and I will re-arrange it to:foo = ['shipper_id','period','shipper']
- Replace it in your df:
df = df[foo]