diff --git a/RELEASE.rst b/RELEASE.rst index 2c47c043dd84d..ae98884f0f683 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -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 diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 882f4f5559a92..70fe378ad3c07 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -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): diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py index bc717a0fbf6d1..002282a21162d 100644 --- a/pandas/tests/test_indexing.py +++ b/pandas/tests/test_indexing.py @@ -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)