Skip to content

BUG: GH3449 .loc was not raising when passed an integer list #3451

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
Apr 25, 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
2 changes: 2 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ pandas 0.12.0
lacking. (GH3164_)
- Fix to_csv issue when having a large number of rows and ``NaT`` in some
columns (GH3437_)
- ``.loc`` was not raising when passed an integer list (GH3449_)

.. _GH3164: https://github.com/pydata/pandas/issues/3164
.. _GH3251: https://github.com/pydata/pandas/issues/3251
.. _GH3379: https://github.com/pydata/pandas/issues/3379
.. _GH3038: https://github.com/pydata/pandas/issues/3038
.. _GH3437: https://github.com/pydata/pandas/issues/3437
.. _GH3449: https://github.com/pydata/pandas/issues/3449



Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ def _getitem_tuple(self, tup):
except IndexingError:
pass

# no multi-index, so validate all of the indexers
self._has_valid_tuple(tup)

# ugly hack for GH #836
if self._multi_take_opportunity(tup):
return self._multi_take(tup)

# no multi-index, so validate all of the indexers
self._has_valid_tuple(tup)

# no shortcut needed
retval = self.obj
for i, key in enumerate(tup):
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ def test_loc_getitem_int_slice(self):
expected = df[10]
assert_frame_equal(result,expected)

def test_loc_to_fail(self):

# GH3449
df = DataFrame(np.random.random((3, 3)),
index=['a', 'b', 'c'],
columns=['e', 'f', 'g'])

# raise a KeyError?
self.assertRaises(KeyError, df.loc.__getitem__, tuple([[1, 2], [1, 2]]))

def test_loc_getitem_label_slice(self):

# label slices (with ints)
Expand Down