[英]Getting the row with max value in Pandas
Find the most recent date:查找最近的日期:
recent_date = df['date'].max()
And then get the dataframe with the recent date:然后获取具有最近日期的数据框:
df[df['date'] == recent_date]
To get the row with Top n dates (say top 2 dates),要获得前 n 个日期的行(比如前 2 个日期),
top_2 = df['date'].nlargest(2)
df[df['date'].isin(top_2)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.