To replace the columns of the pandas DataFrame, use ix to specify the column names in the order after the replacement.
Example
df
'''
Suppose this is a dataframe df
a b c
A 0 1 2
S 5 6 7
'''
#When I run this code ...
df.ix[:,['a','c','b']]
'''
It will be as follows
a c b
A 0 2 1
S 5 7 6
'''
That's all for the points I stumbled upon as a pandas beginner.
Postscript: Of course, you can specify the column index numerically.
Recommended Posts