df = pd.DataFrame({
    'pid': [10,20,10,30], 
    'sid': [1,1,2,3],
    'data1': ['a','b','a','c'],
    'data2': ['q','w','e','e'],
})
   pid  sid data1 data2
0   10    1     a     q
1   20    1     b     w
2   10    2     a     e
3   30    3     c     e
Can be many rows data. Perhaps, can use index = ['pid', 'sid'].
How I can transform it to Excel in the following format?
That is, index by pid, select row blocks by the  'sid', with iteration by incrementation of it. Then add these as blocks of columns to the right.
sid   1             2              3
pid   data1  data2  data1  data2   data1  data2
 10   a      q      a      e       None   None
 20   b      w      None   None    None   None
 30   None   None   None   None    c      e
Thank you.
 
    