Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a sketch</p> <p>Create your input series</p> <pre><code>In [24]: x = zip(pd.date_range('20130101',periods=1000000,freq='s').asi8/1000000000,np.random.randn(1000000)) In [49]: x[0] Out[49]: (1356998400, 1.2809949462375376) </code></pre> <p>Create the frame</p> <pre><code>In [25]: df = DataFrame(x,columns=['time','value']) </code></pre> <p>Make the dates a bit random (to simulate some data)</p> <pre><code>In [26]: df['time1'] = df['time'] + np.random.randint(0,10,size=1000000) </code></pre> <p>Convert the epoch seconds to datetime64[ns] dtype</p> <pre><code>In [29]: df['time2'] = pd.to_datetime(df['time1'],unit='s') </code></pre> <p>Difference the series (to create timedeltas)</p> <pre><code>In [32]: df['diff'] = df['time2'].diff() </code></pre> <p>Looks like this</p> <pre><code>In [50]: df Out[50]: time value time1 time2 diff 0 1356998400 -0.269644 1356998405 2013-01-01 00:00:05 NaT 1 1356998401 -0.924337 1356998401 2013-01-01 00:00:01 -00:00:04 2 1356998402 0.952466 1356998410 2013-01-01 00:00:10 00:00:09 3 1356998403 0.604783 1356998411 2013-01-01 00:00:11 00:00:01 4 1356998404 0.140927 1356998407 2013-01-01 00:00:07 -00:00:04 5 1356998405 -0.083861 1356998414 2013-01-01 00:00:14 00:00:07 6 1356998406 1.287110 1356998412 2013-01-01 00:00:12 -00:00:02 7 1356998407 0.539957 1356998414 2013-01-01 00:00:14 00:00:02 8 1356998408 0.337780 1356998412 2013-01-01 00:00:12 -00:00:02 9 1356998409 -0.368456 1356998410 2013-01-01 00:00:10 -00:00:02 10 1356998410 -0.355176 1356998414 2013-01-01 00:00:14 00:00:04 11 1356998411 -2.912447 1356998417 2013-01-01 00:00:17 00:00:03 12 1356998412 -0.003209 1356998418 2013-01-01 00:00:18 00:00:01 13 1356998413 0.122424 1356998414 2013-01-01 00:00:14 -00:00:04 14 1356998414 0.121545 1356998421 2013-01-01 00:00:21 00:00:07 15 1356998415 -0.838947 1356998417 2013-01-01 00:00:17 -00:00:04 16 1356998416 0.329681 1356998419 2013-01-01 00:00:19 00:00:02 17 1356998417 -1.071963 1356998418 2013-01-01 00:00:18 -00:00:01 18 1356998418 1.090762 1356998424 2013-01-01 00:00:24 00:00:06 19 1356998419 1.740093 1356998428 2013-01-01 00:00:28 00:00:04 20 1356998420 1.480837 1356998428 2013-01-01 00:00:28 00:00:00 21 1356998421 0.118806 1356998427 2013-01-01 00:00:27 -00:00:01 22 1356998422 -0.935749 1356998427 2013-01-01 00:00:27 00:00:00 </code></pre> <p>Calc median</p> <pre><code>In [34]: df['diff'].median() Out[34]: 0 00:00:01 dtype: timedelta64[ns] </code></pre> <p>Calc mean</p> <pre><code>In [35]: df['diff'].mean() Out[35]: 0 00:00:00.999996 dtype: timedelta64[ns] </code></pre> <p>Should get you started</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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