Background
I have a large data frame with 2 column levels, but 1 row level, and I'm trying to sort it as follows: level 0: in alphabetical order; Level 1: custom view.
Example
import pandas as pd dictionary = {'A' : {'M': [1,2,3,4,5], 'L': [6,7,8,9,1], 'F': [3,5,1,3,5] }, 'C' : {'M': [2,3,4,5,6], 'L': [7,8,9,1,2], 'F': [0,1,6,3,5] }, 'B' : {'M': [1,5,2,5,3], 'L': [9,5,6,3,4], 'F': [6,2,7,1,5] } } reform = {(outerKey, innerKey): values for outerKey, innerDict in dictionary.iteritems() for innerKey, values in innerDict.iteritems()} pd.DataFrame(reform,index=['g','h','i','j','k'])
Then i have
# ABC
Question
How can I specify the column order as A, B, C at level 0 and F, M, L at level 1?
#
I tried with pd.IndexSlice and .loc , but I still get only letter order.