Accessing total_seconds() in pandas data column
<p>I want to create a new column in a pandas data frame that is the elapsed time from the start of the data frame.  I am importing a log file into a data frame which has datatime info, but accessing the <code>total_seconds()</code> function in <code>s_df['delta_t']</code> is not working.  It works if I access the individual elements of the column (<code>s_df['delta_t'].iloc[8].total_seconds()</code>), but I want to create a new column with total_seconds() and my attempts are failing.</p>

<pre><code>s_df['t'] = s_df.index  # s_df['t] is a column of datetime
s_df['delta_t'] = ( s_df['t'] - s_df['t'].iloc[0]) # time since start of data frame
s_df['elapsed_seconds'] = # want column s_df['delta_t'].total_seconds()
</code></pre>