Skip to content

IndexError when indexing into numpy array using a Series #8310

Closed
@mirage007

Description

@mirage007

I'm getting a weird error in 0.14.1 that i didn't have in 0.10.1

>>> import numpy as np
>>> import pandas
>>> np.__version__
Out[8]: '1.8.2'
>>> pandas.__version__
Out[9]: '0.14.1'
>>> a = np.arange(10)
>>> b = pandas.Series([1,2,3])
>>> a[b]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2746, in run_code
    exec code_obj in self.user_global_ns, self.user_ns
  File "<ipython-input-17-a686c4bc0a37>", line 1, in <module>
    a[b]
IndexError: unsupported iterator index

I would have expected to get something like array([1,2,3]), note this works if i use .values

>>> a[b.values]
Out[20]: array([1, 2, 3])

This would print out as expected in 0.10.1:

In [28]: numpy.__version__
Out[28]: '1.6.2'
In [29]: pandas.__version__
Out[29]: '0.10.1'
In [30]: a = numpy.arange(10)
In [31]: b = pandas.Series([1,2,3])
In [32]: a[b]
Out[32]: array([1, 2, 3])

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions