Skip to content

Commit 1e2b447

Browse files
committed
Merge pull request #3451 from jreback/GH3449
BUG: GH3449 .loc was not raising when passed an integer list
2 parents 26e3fc8 + 91370ea commit 1e2b447

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

RELEASE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ pandas 0.12.0
4949
lacking. (GH3164_)
5050
- Fix to_csv issue when having a large number of rows and ``NaT`` in some
5151
columns (GH3437_)
52+
- ``.loc`` was not raising when passed an integer list (GH3449_)
5253

5354
.. _GH3164: https://github.com/pydata/pandas/issues/3164
5455
.. _GH3251: https://github.com/pydata/pandas/issues/3251
5556
.. _GH3379: https://github.com/pydata/pandas/issues/3379
5657
.. _GH3038: https://github.com/pydata/pandas/issues/3038
5758
.. _GH3437: https://github.com/pydata/pandas/issues/3437
59+
.. _GH3449: https://github.com/pydata/pandas/issues/3449
5860

5961

6062

pandas/core/indexing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ def _getitem_tuple(self, tup):
253253
except IndexingError:
254254
pass
255255

256+
# no multi-index, so validate all of the indexers
257+
self._has_valid_tuple(tup)
258+
256259
# ugly hack for GH #836
257260
if self._multi_take_opportunity(tup):
258261
return self._multi_take(tup)
259262

260-
# no multi-index, so validate all of the indexers
261-
self._has_valid_tuple(tup)
262-
263263
# no shortcut needed
264264
retval = self.obj
265265
for i, key in enumerate(tup):

pandas/tests/test_indexing.py

+10
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,16 @@ def test_loc_getitem_int_slice(self):
483483
expected = df[10]
484484
assert_frame_equal(result,expected)
485485

486+
def test_loc_to_fail(self):
487+
488+
# GH3449
489+
df = DataFrame(np.random.random((3, 3)),
490+
index=['a', 'b', 'c'],
491+
columns=['e', 'f', 'g'])
492+
493+
# raise a KeyError?
494+
self.assertRaises(KeyError, df.loc.__getitem__, tuple([[1, 2], [1, 2]]))
495+
486496
def test_loc_getitem_label_slice(self):
487497

488498
# label slices (with ints)

0 commit comments

Comments
 (0)