'DataFrame'对象是可变的,因此它们不能被散列|| GROUPBY()。适用

时间:2018-03-27 07:27:08

标签: python-3.x pandas

我遇到了大熊猫的麻烦,下面是代码:

print(right_df)

enter image description here

print(right_top)

enter image description here

g = right_df.groupby('exam_id').apply(right_top)
print(g)

错误是“TypeError:'DataFrame'对象是可变的,因此它们不能被散列” 我怎么解决呢?

1 个答案:

答案 0 :(得分:1)

您应该将功能传递给apply(...)。 在您的代码中,您传递了 DataFrame ,因此,pandas尝试调用对象pandas.DataFrame的数据帧(__call__方法),从而导致错误。

请参阅 apply here的说明。

为了帮助您解决具体问题,请提供有关您意图的更多信息。