Pandas Dataframe Multiindex Merge

前端 未结 4 432
萌比男神i
萌比男神i 2020-12-16 14:31

I wanted to ask a questions regarding merging multiindex dataframe in pandas, here is a hypothetical scenario:

arrays = [[\'bar\', \'bar\', \'baz\', \'baz\'         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 15:13

    Assign it by combine_first

    s1.combine_first(s2)
    Out[19]: 
                        s1        s2
    first second                    
    bar   one     0.039203  0.795963
          two     0.454782 -0.222806
    baz   one     3.101120 -0.645474
          two    -1.174929 -0.875561
    foo   one    -0.887226  1.078218
          two     1.507546 -1.078564
    qux   one     0.028048  0.042462
          two     0.826544 -0.375351
    
    # s2.combine_first(s1)
    

提交回复
热议问题