DataFrame interpolate method error when using keyword limit #7173

Closed
JohnSmizz opened this Issue May 19, 2014 · 5 comments

Comments

Projects
None yet
3 participants

Hi-

interpolate works fine on most of my datasets but I've just encountered for the first time a new error when attempting to run this method.

IndexError: arrays used as indices must be of integer (or boolean) type

I'm not sure how/if its sensible to paste the dataset I used somehow on here (along with the datetimeindex) so you can attempt to replicate this error -- happy to do so if you tell me how.
This error only occurs when I place a restriction via the limit keyword. Eg.

temp1df.interpolate(method='time') works fine.
temp1df.interpolate(method='time', limit=4) yields above error.

temp1df is a dataframe with a datetimeindex with a 208 count, and a datetimeindex of 576 length.
I am running 0.13.1 on 3.3.3 on a windows machine.

Full traceback below:

Traceback (most recent call last):

  File "<ipython-input-88-394bcc7f44e2>", line 1, in <module>
    temp1df.between_time('08:00', '18:00').interpolate(limit=4)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\generic.py", line 2532, in interpolate
    **kwargs)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\internals.py", line 2404, in interpolate
    return self.apply('interpolate', *args, **kwargs)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\internals.py", line 2375, in apply
    applied = getattr(blk, f)(*args, **kwargs)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\internals.py", line 821, in interpolate
    **kwargs)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\internals.py", line 882, in _interpolate
    interp_values = np.apply_along_axis(func, axis, data)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\numpy\lib\shape_base.py", line 79, in apply_along_axis
    res = func1d(arr[tuple(i.tolist())],*args)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\internals.py", line 879, in func
    bounds_error=False, **kwargs)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\common.py", line 1380, in interpolate_1d
    violate_limit = _interp_limit(invalid, limit)

  File "C:\WinPython3.3.3.2\python-3.3.3.amd64\lib\site-packages\pandas\core\common.py", line 1374, in _interp_limit
    return all_nans[violate] + limit

IndexError: arrays used as indices must be of integer (or boolean) type
Contributor

jreback commented May 19, 2014

pls post a complete example with dataset (or a link), code you use to read in and what reproduces the error, and pd.``print_versions()

the more info the better

jreback added this to the 0.14.1 milestone May 19, 2014

@jreback jreback modified the milestone: 0.15.0, 0.14.1 Jun 26, 2014

ianp commented Jul 2, 2014

I've just run across the same issue, a small example is pasted in below.

I should also note that although in this code resampling the series seems to fix the issue, I have other code for which this is not the case (I'll try to get an better example that I'm able to share).

import pandas as pd

input_data = {
    pd.datetime(2012, 1, 7): 234.0,
    pd.datetime(2012, 1,14): 123.4,
    pd.datetime(2012, 1,21): 124.1,
    pd.datetime(2012, 1,28): 346.3,
    pd.datetime(2012, 3,10): 235.7,
    pd.datetime(2012, 3,24): 346.2
}

s = pd.Series(input_data)
print s
print s.interpolate()
print s.resample('W-SAT').interpolate(limit=1)

# fails!
print s.interpolate(limit=1)

I've tried this with Pandas versions 0.13.1 and 0.14 both running under python 2.7.6.

Contributor

jreback commented Jul 2, 2014

@ianp this seems to be a different issue, though the results look ok to me. Pls open a new issue with a reproducing case (and the expected output)

ianp commented Jul 7, 2014

Done, issue #7679.

@jreback jreback modified the milestone: 0.15.0, 0.15.1 Jul 7, 2014

Contributor

jreback commented Sep 9, 2014

@TomAugspurger have a look?

jreback closed this in #8235 Sep 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment