25

I have an example dataframe (df) for 2 products:

                         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

Is there a way to retrieve the last index value of a dataframe only. So in this example the date value I need retrieved is 2015-03-25?

2 Answers 2

34

The following gives you the last index value:

df.index[-1]

Example:

In [37]:

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

Or you could access the index attribute of the tail:

In [40]:

df.tail(1).index[0]
Out[40]:
Timestamp('2015-03-25 00:00:00')
Sign up to request clarification or add additional context in comments.

Comments

10

Old post, but df.last_valid_index() also works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.