Python 用多索引求两个数据帧的和

Python 用多索引求两个数据帧的和,python,pandas,Python,Pandas,我想对两个数据帧求和,但在输出中丢失了一些数据。多索引29193第一级中的所有数据都已消失 输入ext\u bal: 2019-10-23 2019-10-24 app_vendor_id currency 3 DASH 0.000000e+00 0.000000e+00 ETC 0.000000e+00

我想对两个数据帧求和,但在输出中丢失了一些数据。多索引
29193
第一级中的所有数据都已消失

输入
ext\u bal

                          2019-10-23    2019-10-24
app_vendor_id currency                            
3             DASH      0.000000e+00  0.000000e+00
              ETC       0.000000e+00  0.000000e+00
              XRP       1.102733e+06  1.102733e+06
29193         BCH       0.000000e+00  0.000000e+00
              BSV       0.000000e+00  0.000000e+00
              BTC       4.991005e+00  4.991005e+00
              BTG       4.990997e+00  4.990997e+00
              DASH      0.000000e+00  0.000000e+00
              ENJ       0.000000e+00  0.000000e+00
              ETC       0.000000e+00  0.000000e+00
              ETH       3.017995e+01  3.017995e+01
输入
ext\u bal\u ex

created_at              2019-10-23 00:00:00  2019-10-24 00:00:00
app_vendor_id currency                                          
 3             DASH               200.000000           200.000000
               ETC               2000.000000          2000.000000
               XRP              18900.000000         18900.000000
输出:

                         2019-10-23    2019-10-24
app_vendor_id currency                           
 3             DASH      2.000000e+02  2.000000e+02
               ETC       2.000000e+03  2.000000e+03
               XRP       1.121633e+06  1.121633e+06
 29193         BCH       0.000000e+00  0.000000e+00
               BSV       0.000000e+00  0.000000e+00
               BTC       0.000000e+00  0.000000e+00
               BTG       0.000000e+00  0.000000e+00
               DASH      0.000000e+00  0.000000e+00
               ENJ       0.000000e+00  0.000000e+00
               ETC       0.000000e+00  0.000000e+00
               ETH       0.000000e+00  0.000000e+00
要将我所做的两个数据帧相加:

ext_bal = (ext_bal + ext_bal_ex).fillna(0)
有什么办法解决这个问题吗?

你可以这样做

ext_bal.add(ext_bal_ex,fill_value=0)

谢谢,这很有效。我以前试过pd.sum,但没用。我需要断定pd.add总是比pd.sum好吗?@mamadede似乎更适合你的情况