Set order of columns in pandas dataframe

Is there a way to reorder columns in pandas dataframe based on my personal preference (i.e. not alphabetically or numerically sorted, but more like following certain conventions)?

Simple example:

    frame = pd.DataFrame({
            'one thing':[1,2,3,4],
            'second thing':[0.1,0.2,1,2],
            'other thing':['a','e','i','o']})

produces this:

       one thing other thing  second thing
    0          1           a           0.1
    1          2           e           0.2
    2          3           i           1.0
    3          4           o           2.0

But instead, I would like this:

       one thing second thing  other thing
    0          1           0.1           a
    1          2           0.2           e
    2          3           1.0           i
    3          4           2.0           o

(Please, provide a generic solution rather than specific to this case. Many thanks.)

Just select the order yourself by typing in the column names. Note the double brackets:

    frame = frame[['column I want first', 'column I want second'...etc.]]


Back to homepage or read more recommendations: