Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 访问dataframe的最后一个索引值_Python_Pandas - Fatal编程技术网

Python 访问dataframe的最后一个索引值

Python 访问dataframe的最后一个索引值,python,pandas,Python,Pandas,我有两种产品的数据帧(df)示例: BBG.XAMS.FUR.S BBG.XAMS.MT.S date 2014-10-23 -2368.850388 0.000000 2014-10-24

我有两种产品的数据帧(df)示例:

                         BBG.XAMS.FUR.S               BBG.XAMS.MT.S
date                                                               
2014-10-23                 -2368.850388                    0.000000
2014-10-24                  6043.456178                    0.000000
2015-03-23                    -0.674996                   -0.674997
2015-03-24                    82.704951                   11.868748
2015-03-25                   -11.027327                   84.160210

是否有方法仅检索数据帧的最后一个索引值。因此,在本例中,我需要检索的日期值是2015-03-25?

以下给出了最后一个索引值:

df.index[-1]
例如:

In [37]:

df.index[-1]
Out[37]:
Timestamp('2015-03-25 00:00:00')
或者您可以访问
尾部的index属性

In [40]:

df.tail(1).index[0]
Out[40]:
Timestamp('2015-03-25 00:00:00')

旧帖子,但
df.last\u valid\u index()
也可以使用