当使用不是“按顺序”的MultiIndex连接两个pandas数据帧时,我的pandas安装使python崩溃,错误代码为0xC00000FD。我花了一段时间才找到我的虫子,当我发现它时,我更加困惑。为什么会发生这种情况,我应该如何更好地发现它?
请考虑以下代码:
import pandas as pd
df = pd.DataFrame.from_records([
("foo", 1, .1),
("foo", 2, .2),
("bar", 1, .3),
("bar", 2, .4)
], columns=["Level1", "Level2", "Value"])
df2 = df.set_index(["Level1","Level2"])
df3 = df.set_index(["Level2","Level1"])
combination = pd.merge(left=df2, right=df2, left_index=True, right_index=True)
print("ok")
combination2 = pd.merge(left=df2, right=df3, left_index=True, right_index=True)
print("fail")
它给出了以下输出:
Level1 Level2 Value
0 foo 1 0.1
1 foo 2 0.2
Value
Level1 Level2
foo 1 0.1
2 0.2
Value
Level2 Level1
1 foo 0.1
2 foo 0.2
ok
Process finished with exit code -1073741571 (0xC00000FD)
问题出现了,当我有一张桌子,做了一些枢轴/融化,并希望回到原始的多索引并加入我的结果。起初我不明白错误信息。从这个页面我了解到错误代码是堆栈溢出。从这个PR到大熊猫,我了解到递归与计算组索引有某种关系。这些信息使我能够追捕我的错误并创建一个最小的再现示例。
现在问我的问题:
编辑所述错误发生在迄今为止的最新python和pandas,pandas 0.24.2和python 3.7.3
发布于 2019-05-29 15:28:49
正如我在评论中所说,在pandas中,0.21.1 pandas会产生错误“多个索引上的多个级别重叠合并未实现”。
查看目录“pandas / core / indexes / base.py”中的pandas库。这是我的pandas版本中引发错误的地方:
3200 if len(overlap) > 1:
-> 3201 raise NotImplementedError("merging with more than one level "
3202 "overlap on a multi-index is not "
3203 "implemented")
https://stackoverflow.com/questions/-100006847
复制相似问题