How can I interpolate accelerometer data in pandas into fixed sampling rate?
<p>I have a frame with accelerometer data, collected from an iPhone device. The avg sampling rate is 100Hz, but I'd like to have a fixed one with all the data (x, y, z) interpolated. Is that possible in pandas?</p>

<p>For example, here is the head of my df:</p>

<pre><code>ts          x           y           z
0.006960    -0.075324   -0.175405   0.167105
0.016970    -0.048325   -0.186265   0.180108
0.026949    -0.017635   -0.158964   0.215963
0.036959    -0.097063   -0.063350   0.256945
0.046969    -0.139939   -0.046091   0.179085
...
</code></pre>

<p>What I need it to have a fixed sampling rage of 100Hz, so that the ts looks like:
<code>0.00, 0.01, 0.02, 0.03 ... 0.99, 1.00, 1.01 ...</code></p>

<p>Thank you for you help in advance.</p>

<p>Index your dataframe with <code>ts</code>:</p>

<pre><code>df = df.set_index('ts')
</code></pre>

<p>Create the index you need:</p>

<pre><code>index2 = pd.Index(pd.np.arange(0.00, 1.00, .01))
</code></pre>

<p>Merge it with the current index and reindex the dataframe to get additional rows:</p>

<pre><code>df = df.reindex(df.index.union(index2))
</code></pre>

<p>Interpolate:</p>

<pre><code>df.interpolate()
</code></pre>

python pandas