Answers for "shuffle columns pandas"

1

shuffle columns pandas

#Reshuffle the column names of the dataframe called 'data'
data = data[['Year','Sales',
 'COGS',
 'Operating Exp',
 'Other Income',
 'Financing Charges',
 'Zakat',
 'Income Tax',
 'Net Income',
 'CFO',
 'CFI',
 'Free Cash Flow',
 'Shareholder Equity',
 'Dividends',
 'EPS']]
Posted by: Guest on August-13-2021
0

rearrange columns pandas

You could also do something like this:

df = df[['mean', '0', '1', '2', '3']]
You can get the list of columns with:

cols = list(df.columns.values)
The output will produce:

['0', '1', '2', '3', 'mean']
Posted by: Guest on August-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language