Closed
Description
Hello, I recently stumbled across this:
df1 = pd.DataFrame({'a':[1.,2.,3.,4.,nan,6,7,8]}, dtype='<f4')
df1.a.interpolate(inplace=True, downcast=None)
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-9-bf0994f72664> in <module>()
----> 1 df1.a.interpolate(inplace=True, downcast=None)
C:\Program Files\Python27\lib\site-packages\pandas\core\generic.pyc in interpolate(self, method, axis, limit, inplace, downcast, **kwargs)
2304 if axis == 1:
2305 res = res.T
-> 2306 return res
2307
2308 #----------------------------------------------------------------------
UnboundLocalError: local variable 'res' referenced before assignment
The problem arises with setting inplace to True regardless of 'downcast'.
But speaking of which: running interpolate() without any options, I would excpect to keep data types by default! I often chunk through datasets and glue them together with to_hdf. It took me a while to figure out that a float column in one chunk had just zeros in it so interpolate downcasted it to int => to_hdf raised on appending.
Thx in advance