Skip to content

BUG: Treat a list/ndarray identically for iloc indexing with list-like (GH5006) #5134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ API Changes
(:issue:`4501`)
- Support non-unique axes in a Panel via indexing operations (:issue:`4960`)


Internal Refactoring
~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -566,7 +565,7 @@ Bug Fixes
- Provide automatic conversion of ``object`` dtypes on fillna, related (:issue:`5103`)
- Fixed a bug where default options were being overwritten in the option
parser cleaning (:issue:`5121`).

- Treat a list/ndarray identically for ``iloc`` indexing with list-like (:issue:`5006`)

pandas 0.12.0
-------------
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,9 @@ def _getitem_axis(self, key, axis=0):
else:

if _is_list_like(key):
pass

# force an actual list
key = list(key)
else:
key = self._convert_scalar_indexer(key, axis)

Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,15 @@ def test_iloc_getitem_list_int(self):

# list of ints
self.check_result('list int', 'iloc', [0,1,2], 'ix', { 0 : [0,2,4], 1 : [0,3,6], 2: [0,4,8] }, typs = ['ints'])
self.check_result('list int', 'iloc', [2], 'ix', { 0 : [4], 1 : [6], 2: [8] }, typs = ['ints'])
self.check_result('list int', 'iloc', [0,1,2], 'indexer', [0,1,2], typs = ['labels','mixed','ts','floats','empty'], fails = IndexError)

# array of ints
# (GH5006), make sure that a single indexer is returning the correct type
self.check_result('array int', 'iloc', np.array([0,1,2]), 'ix', { 0 : [0,2,4], 1 : [0,3,6], 2: [0,4,8] }, typs = ['ints'])
self.check_result('array int', 'iloc', np.array([2]), 'ix', { 0 : [4], 1 : [6], 2: [8] }, typs = ['ints'])
self.check_result('array int', 'iloc', np.array([0,1,2]), 'indexer', [0,1,2], typs = ['labels','mixed','ts','floats','empty'], fails = IndexError)

def test_iloc_getitem_dups(self):

# no dups in panel (bug?)
Expand Down