终于解决了,因为我想要row1_order中的每个索引,row2_order中的所有10个索引,所以我将它们更改为这些值:
row1_order = ['Instruction','Instruction','Instruction','Instruction','Instruction','Instruction','Instruction','Instruction','Instruction','Instruction',
'Support Services','Support Services','Support Services','Support Services','Support Services','Support Services','Support Services','Support Services','Support Services','Support Services',
'Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.','Executive Admin.',
'School Admin.','School Admin.','School Admin.','School Admin.','School Admin.','School Admin.','School Admin.','School Admin.','School Admin.','School Admin.',
'Business Services','Business Services','Business Services','Business Services','Business Services','Business Services','Business Services','Business Services','Business Services','Business Services',
'Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant','Op. & Maint. Of Plant',
'Transportation','Transportation','Transportation','Transportation','Transportation','Transportation','Transportation','Transportation','Transportation','Transportation',
'Benefits','Benefits','Benefits','Benefits','Benefits','Benefits','Benefits','Benefits','Benefits','Benefits',
'Debt Service','Debt Service','Debt Service','Debt Service','Debt Service','Debt Service','Debt Service','Debt Service','Debt Service','Debt Service',
'Transfers','Transfers','Transfers','Transfers','Transfers','Transfers','Transfers','Transfers','Transfers','Transfers']
row2_order = ['Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service',
'Wages', 'Benefits', 'Property Service', 'Professional Services',
'Debt Service','Supplies','Other Services','Equipment',
'Dues & Fees', 'Transfer to Food Service']
然后运行
multi_index = [np.array(row1_order), np.array(row2_order)]
my_pivot_table = my_pivot_table.reindex_axis(multi_index, axis = 0)
做了我想要的。