2017-02-28 173 views
0

这里有两个大熊猫dataframes:如何合并两个多索引熊猫数据框?

      cq 
Assay Time Repeat   
ACTB 0 1  22.000170 
      2  21.882603 
      3  22.064980 
      4  21.838563 
      5  22.089467 


          cq 
Assay Time Repeat   
B2M 0 1  21.451027 
      2  21.374013 
      3  21.334360 
      4  21.395817 
      5  21.441243 

我怎样才能将它们合并,使它看起来像这样:

   ACTB  B2M 
Time Repeat   
0 1  22.000170 21.451027 
    2  21.882603 21.374013 
    3  22.064980 21.334360 
    4  21.838563 21.395817 
    5  22.089467 21.441243 

我已经试过pandas.merge功能,但没有喜悦。

回答

0

我想出了答案。我们可以使用unstack耦合到concat函数

df_list= [i.unstack(level=0) for i in df_list] 
print pandas.concat(df_list,axis=1)