从大 pandas 数据帧获取最小和最大日期 [英] Getting min and max Date's from a pandas dataframe
本文介绍了从大 pandas 数据帧获取最小和最大日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从数据框主轴获取最小和最大日期?
How do I get the min and max Date's from a dataframes major axis?
value
Date
2014-03-13 10000.000
2014-03-21 2000.000
2014-03-27 2000.000
2014-03-17 200.000
2014-03-17 5.000
2014-03-17 70.000
2014-03-21 200.000
2014-03-27 5.000
2014-03-27 25.000
2014-03-31 0.020
2014-03-31 12.000
2014-03-31 0.022
本质上我想一种获得最小和最大日期的方法,即 2014-03-13
和 2014-03-31
。我尝试使用 numpy.min
或 df.min(axis = 0)
,我可以得到最小或最大值,但这不是我想要的
Essentially I want a way to get the min and max dates,i.e. 2014-03-13
and 2014-03-31
. I tried using numpy.min
or df.min(axis=0)
, I'm able to get the min or max value but thats not what I want
推荐答案
'Date'是你的索引,所以你想做,
'Date' is your index so you want to do,
print df.index.min()
print df.index.max()
2014-03-13 00:00:00
2014-03-31 00:00:00
这篇关于从大 pandas 数据帧获取最小和最大日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文