I've been using Series.interpolate(), and have noticed that, while it
leaves NaN entries alone if they precede a non-null value, it blows up if
there are no non-null entries. Wouldn't it make more sense just to leave
completely null series alone (so the user doesn't have to manually check
for this case)? Here's an example:
1) This one works:
S1 = Series([np.nan, 2.0])
print S1.interpolate()
-------
0 NaN
1 2
dtype: float64
--------
2) This one blows up:
S2 = Series([np.nan, np.nan])
print S2.interpolate()
--------
ValueError Traceback (most recent call last)
<ipython-input-49-620b22122e43> in <module>()
3
4 S2 = Series([np.nan, np.nan])
----> 5 print S2.interpolate()
/RHS/packages/anaconda/pandas/pandas/core/series.pyc in interpolate(self,
method)
3191 result = values.copy()
3192 result[firstIndex:][invalid] = np.interp(inds[invalid],
inds[valid],
-> 3193
values[firstIndex:][valid])
3194
3195 return Series(result, index=self.index, name=
self.name)
/Users/stanton/anaconda/lib/python2.7/site-packages/numpy/lib/function_base
.pyc in interp(x, xp, fp, left, right)
1067 return compiled_interp([x], xp, fp, left, right).item()
1068 else:
-> 1069 return compiled_interp(x, xp, fp, left, right)
1070
1071
ValueError: array of sample points is empty