A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/6281 below:

Series (DataFrame column) inplace interpolate UnboundLocalError · Issue #6281 · pandas-dev/pandas · GitHub

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4