删除列提供了Exception:Reindexing仅对具有唯一值的Index对象有效

时间:2013-10-28 17:55:58

标签: python python-3.x pandas

我有以下表格的数据:

red_id            test1 test2   test3......
815298969_mid1    pass  fail    pass
815298969_mid2    fail  pass    pass
815298969_final   pass  pass    pass
814248989_mid1    pass  fail    fail
814248989_mid2    pass  fail    pass
814248989_final   pass  pass    fail
816592961_mid1    fail  pass    pass
816592961_mid2    pass  pass    pass
816592961_final   pass  pass    pass
......

我有一个pandas数据框,上面有学生详细信息,我按照'red_id'列分组

    grouped = data_frame.groupby('red_id')

..... 然后在我的脚本中我有循环

for red, stud_data in grouped:
......
        data = data.drop('red_id', axis=1)

我试图从数据帧中删除一个'red_id'列,因为我想要for循环中的pass / fail类平均值,如上所示。 它给了我例外:

Exception: Reindexing only valid with uniquely valued Index objects

0 个答案:

没有答案