从多索引数据框中删除重复索引

时间:2016-07-14 16:48:32

标签: python pandas dataframe pivot-table

我在使用DataFrame之后收到pivot_table,其中包含一些重复的索引,如下所示:

enter image description here

如果你查看底部条目中的第二个条目,它只有1 memberid代表2 testscoreidDataFrame中有一个名为ScoreRatio的相应列,我在此处未显示。我只想让testscoreid保持较高的ScoreRatio值。

可能会找到数据here

我尝试使用以下代码,但似乎没有任何影响:

selectedTestsPivotCorrect.reset_index(level=['memberid'])
selectedTestsPivotCorrect.groupby(selectedTestsPivotCorrect.index).last()

如何对memberid中出现的所有重复(或可能的三元组,四元组等)DataFrame执行此操作?

任何指针都会受到高度赞赏。

0 个答案:

没有答案
相关问题