pandas - get most recent value of a particular column indexed by another column (get maximum value of a particular column indexed by another column)

前端 未结 6 690
深忆病人
深忆病人 2020-12-01 11:05

I have the following dataframe:

   obj_id   data_date   value
0  4        2011-11-01  59500    
1  2        2011-10-01  35200 
2  4        2010-07-31  24860          


        
6条回答
  •  误落风尘
    2020-12-01 11:16

    This is another possible solution. I believe it's is the fastest.

    df.loc[df.groupby('obj_id').data_date.idxmax(),:]
    

提交回复
热议问题