Pandas: Get datetime index value from row
<p>I have a dataframe with datetime type column set to index. 
I want to process the data per row with apply function. how can I access the index value of the current row?</p>

<pre><code>                      hid      lat        lon  
2016-08-11 10:56:00  549  40.639504 -79.996961   
2016-08-11 10:57:00  639  40.539504 -79.993981   
2016-08-11 10:58:00  749  40.438842 -79.924733 

def f(row):
    # I want to access row idx value here

df['new'] = df.apply(lambda row: f(row), axis=1)
</code></pre>

<p>Since apply will return a Series you could call the name of that Series which represent the index such has:</p>

<pre><code>df['new'] = df.apply(lambda row: row.name, axis=1)
</code></pre>

python datetime pandas