Skip to content

DataFrame interpolate method error when using keyword limit  #7173

Closed
@JohnSmizz

Description

@JohnSmizz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions