蔭試圖讓根據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