Selecting a specific row and column within pandas data array

11,088

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
Share:
11,088

Related videos on Youtube

GCien
Author by

GCien

LARI Am#Astronomer @LowellObservatory, ex-BlackRock FX analyst. @Authorea+d3po+IPython advocate, yt-project user. Starburst+dAGN researcher

Updated on June 04, 2022

Comments

  • GCien
    GCien almost 2 years

    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?