Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Requires numpy >= 1.7. This is for pandas 0.13 (releasing soon). See docs <a href="http://pandas.pydata.org/pandas-docs/dev/timeseries.html#time-deltas" rel="nofollow">here</a></p> <pre><code>In [3]: df = DataFrame(dict(A = Timestamp('20130101'), B = Timestamp('20130101')+ pd.to_timedelta(list(range(5)),unit='D'))) In [4]: df Out[4]: A B 0 2013-01-01 00:00:00 2013-01-01 00:00:00 1 2013-01-01 00:00:00 2013-01-02 00:00:00 2 2013-01-01 00:00:00 2013-01-03 00:00:00 3 2013-01-01 00:00:00 2013-01-04 00:00:00 4 2013-01-01 00:00:00 2013-01-05 00:00:00 [5 rows x 2 columns] In [5]: df.dtypes Out[5]: A datetime64[ns] B datetime64[ns] dtype: object In [6]: df['C'] = df['B']-df['A'] In [7]: df Out[7]: A B C 0 2013-01-01 00:00:00 2013-01-01 00:00:00 00:00:00 1 2013-01-01 00:00:00 2013-01-02 00:00:00 1 days, 00:00:00 2 2013-01-01 00:00:00 2013-01-03 00:00:00 2 days, 00:00:00 3 2013-01-01 00:00:00 2013-01-04 00:00:00 3 days, 00:00:00 4 2013-01-01 00:00:00 2013-01-05 00:00:00 4 days, 00:00:00 [5 rows x 3 columns] In [8]: df.dtypes Out[8]: A datetime64[ns] B datetime64[ns] C timedelta64[ns] dtype: object In [9]: df['C'].astype('timedelta64[s]') Out[9]: 0 0 1 86400 2 172800 3 259200 4 345600 Name: C, dtype: float64 </code></pre> <p>In 0.12 you can do this</p> <pre><code>In [1]: df = DataFrame(dict(A = Timestamp('20130101'), B = [Timestamp('20130101')+timedelta(days=i) for i in range(5) ])) In [2]: df['C'] = df['B']-df['A'] In [3]: Series(df['C'].values / np.timedelta64(1,'s')) Out[3]: 0 0 1 86400 2 172800 3 259200 4 345600 dtype: float64 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload