pandas 找出某列最大值的所在的行

比如说,要根据某一列的最大值找出每个人所在的行,或者说找出每个人数学成绩最高的那一年

gjj_data_meger.groupby('reportno').apply(lambda t: t[t.gettime==t.gettime.max()])

但是要注意的是,这一些的值需要是能用max()计算出来,不然就会报错

TypeError: '>=' not supported between instances of 'str' and 'float'

我们可以先验证df.max()对应的列是否能够计算

原文地址:https://www.cnblogs.com/cgmcoding/p/14298850.html