在Pandas中获取具有最大值的行 [英] Getting the row with max value in Pandas
本文介绍了在Pandas中获取具有最大值的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
具有这样的df:
我想有一个数据框,其中只有最大日期的行.如何执行?
I'd like to have a dataframe with only row with max date in it. How can it be performed?
谢谢!
推荐答案
查找最近的日期:
recent_date = df['date'].max()
然后获取带有最近日期的数据框:
And then get the dataframe with the recent date:
df[df['date'] == recent_date]
这篇关于在Pandas中获取具有最大值的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文