Unable to correctly use Pandas Interpolate over a series
<p>I am trying to use the interpolation functionality provided by Pandas,   <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.interpolate.html" rel="nofollow">here</a> but for some reason, cannot get my Series to adjust to the correct values. I casted them to a float64, but that did not appear to help. Any recommendations?</p>

<p><strong>The code:</strong></p>

<pre><code>for feature in price_data:
    print price_data[feature]
    print "type:"
    print type(price_data[feature])
    newSeries = price_data[feature].astype(float).interpolate()
    print "newSeries: "
    print newSeries
</code></pre>

<p><strong>The output:</strong></p>

<pre><code>0    178.9000
1      0.0000
2    178.1200
Name: open_price, dtype: object
type:
&lt;class 'pandas.core.series.Series'&gt;
newSeries: 
0    178.90
1      0.00
2    178.12
Name: open_price, dtype: float64
</code></pre>

<p>The problem is that there is nothing to interpolate.  I'm assuming you want to interpolate the value where zero is.  In that case, replace the zero with <code>np.nan</code> then interpolate.  One way to do this is</p>

<pre><code>price_data.where(price_data != 0, np.nan).interpolate()

0    178.90
1    178.51
2    178.12
Name: open_price, dtype: float64
</code></pre>

python python-2.7 pandas interpolation series