荫试图让根据GROUPBY的另一列与最大值行,我试图遵从下面给出Python : Getting the Row which has the max value in groups using groupby的解决方案,然而,当你运用它不起作用如何获得多列组的最大值 - by pandas?
annotations.groupby(['bookid','conceptid'], sort=False)['weight'].max()
我得到
bookid conceptid
12345678 3942 0.137271
10673 0.172345
1002 0.125136
34567819 44407 1.370921
5111 0.104729
6160 0.114766
200 0.151629
3504 0.152793
但我想只得到权重最高的行,例如,
bookid conceptid
12345678 10673 0.172345
34567819 44407 1.370921
我想感谢所有帮助
只是一个想法,就这样给你你想要的东西:'annotations.groupby( ['bookid'],sort = False)['weight']。max()' – EdChum 2014-11-07 08:59:48