11

Hopefully this is a quick and simple one. Having looked through the entirity of the pandas.DataFrame documentation I can't quite seem to find exactly what I need. I have a DataFrame as:

           StartDate          End Date
0   10/11/2014 00:00  10/12/2014 12:00
1   12/01/2015 08:00  31/01/2015 07:59
2   15/01/2015 00:00  19/02/2015 15:43

Say, for example, I want to access the value at StartDate column index value 2...i.e, 15/01/2015 00:00 how is this achieved?

2 Answers 2

18

Use loc:

print (df.loc[2, 'StartDate'])
15/01/2015 00:00

or faster at:

print (df.at[2, 'StartDate'])
15/01/2015 00:00

In [199]: %timeit (df.loc[2, 'StartDate'])
10000 loops, best of 3: 147 µs per loop

In [200]: %timeit (df.at[2, 'StartDate'])
100000 loops, best of 3: 6.3 µs per loop
Sign up to request clarification or add additional context in comments.

Comments

1

Try this solution:

df.loc[2, 'StartDate']

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.