pandas - Column order after multi-index unstack -


output after unstacking data. unstacked using multi-columns unstack(['marketdate','class'])

marketdate    2017/08/19 2017/08/18         2017/08/19 class             onpeak     onpeak offpeak    offpeak constraint_id                                          634              -221.65    -165.28 -116.55    -237.97 644                 0.00       2.22    0.00       0.00 1049             -702.05    -936.26 -317.45    -181.72 1281                0.00      -4.68    0.00       0.00 1607             -136.12     -84.74  -31.44     -65.91 

what need see in output marketdate , below onpeak , offpeak, not marketdate onpeaks first , offpeaks later.

this important further processing.

any appreciated.

iiuc, need sort_index axis=1.

df.sort_index(axis=1) 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -