Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pandas 将两个具有多索引的数据帧相加?_Pandas - Fatal编程技术网

Pandas 将两个具有多索引的数据帧相加?

Pandas 将两个具有多索引的数据帧相加?,pandas,Pandas,我们知道dataframe可以通过索引添加另一个dataframe。 虽然我有两个具有多索引的数据帧,但如何在索引中按级别“a”添加它们呢 data3.head() c d e a b 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 data4.head() b d e a c 0 2

我们知道dataframe可以通过索引添加另一个dataframe。 虽然我有两个具有多索引的数据帧,但如何在索引中按级别“a”添加它们呢

data3.head()
        c   d   e
a  b
0  1    2   3   4
5  6    7   8   9
10 11  12  13  14
15 16  17  18  19
20 21  22  23  24
data4.head()
        b   d   e
a  c             
0  2    1   3   4
5  7    6   8   9
10 12  11  13  14
15 17  16  18  19
20 22  21  23  24
25 27  26  28  29
data3 + data4
error:merging with both multi-indexes is not implemented

也许我很困惑,甚至把它们加在一起,但是多索引必须是一个级别。不是多重索引。所以我的问题没有答案!你到底想要什么样的输出?你是在寻找数据3.重置索引(级别=1)+数据4.重置索引(级别=1)?是的,数据3.重置索引(级别=1)+数据4.重置索引(级别=1)是解决方案。谢谢