我有以下形式的数据:
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
......
我有一个带有上述学生详细信息的熊猫数据框,我按“red_id”列对其进行分组
grouped = data_frame.groupby('red_id')
.....然后在我的脚本中我有循环
for red, stud_data in grouped:
......
data = data.drop('red_id', axis=1)
我正在尝试从数据框中删除列“red_id”,因为我希望在 for 循环中通过/失败的类平均值,如上所示。它给了我例外:
Exception: Reindexing only valid with uniquely valued Index objects