interpolate() fails with empty series

54 views
Skip to first unread message

Richard Stanton

unread,
May 20, 2013, 3:23:55 PM5/20/13
to pyd...@googlegroups.com
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



Wouter Overmeire

unread,
May 21, 2013, 3:41:09 PM5/21/13
to pyd...@googlegroups.com



2013/5/20 Richard Stanton <sta...@haas.berkeley.edu>



--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



A new issue has been created for this.
Reply all
Reply to author
Forward
0 new messages