Skip to content

passing Index or Series to iloc fails with old numpy #17193

Closed
@toobaz

Description

@toobaz

Code Sample, a copy-pastable example if possible

>>> s = pd.Series([1,2])    
>>> s.iloc[pd.Series([0])] = 2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/core/indexing.py", line 198, in __setitem__
    self._setitem_with_indexer(indexer, value)
  File "pandas/core/indexing.py", line 619, in _setitem_with_indexer
    value=value)
  File "pandas/core/internals.py", line 3313, in setitem
    return self.apply('setitem', **kwargs)
  File "pandas/core/internals.py", line 3201, in apply
    applied = getattr(b, f)(**kwargs)
  File "pandas/core/internals.py", line 864, in setitem
    values[indexer] = value
IndexError: unsupported iterator index
>>> np.version.version
'1.7.0'

Problem description

This is a consequence of #6168 , which is fixed in more recent numpy versions (but 1.7.0 is still a supported version).

Not 100% sure this is worth fixing (i.e. how interested we are in keeping compatibility with numpy 1.8.0), but the fix is trivial, so I'll just push a PR and let you judge.

Expected Output

Just no error.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-3-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: it_IT.UTF-8
LOCALE: None.None

pandas: 0+unknown
pytest: 3.2.0
pip: None
setuptools: 36.2.7
Cython: None
numpy: 1.7.0
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 1.5
pytz: 2012c
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions