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
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
基本上我想要一种方法来获得最小和最大日期,即。 2014-03-13和2014-03-31。我尝试使用numpy.min或df.min(axis = 0),我能够得到最小值或最大值,但这不是我想要的
2 个解决方案
#1
39
'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
#2
10
min(df['some_property'])
max(df['some_property'])
The build-in function works fine with dataframe
内置函数适用于dataframe
#1
39
'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
#2
10
min(df['some_property'])
max(df['some_property'])
The build-in function works fine with dataframe
内置函数适用于dataframe