Skip to content

Commit d2a80a8

Browse files
committed
CLN: added NotImplementedError when trying to iloc with a mask that has an integer index
(rather than ValueError)
1 parent f02ac25 commit d2a80a8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandas/core/indexing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ class _iLocIndexer(_LocationIndexer):
777777
def _has_valid_type(self, key, axis):
778778
if com._is_bool_indexer(key):
779779
if hasattr(key,'index') and isinstance(key.index,Index):
780+
if key.index.inferred_type == 'integer':
781+
raise NotImplementedError("iLocation based boolean indexing on an integer type is not available")
780782
raise ValueError("iLocation based boolean indexing cannot use an indexable as a mask")
781783
return True
782784

pandas/tests/test_indexing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ def test_iloc_mask(self):
895895
mask = (df.a%2 == 0)
896896
self.assertRaises(ValueError, df.iloc.__getitem__, tuple([mask]))
897897
mask.index = range(len(mask))
898-
self.assertRaises(ValueError, df.iloc.__getitem__, tuple([mask]))
898+
self.assertRaises(NotImplementedError, df.iloc.__getitem__, tuple([mask]))
899899

900900
# ndarray ok
901901
result = df.iloc[np.array([True] * len(mask),dtype=bool)]
@@ -916,7 +916,7 @@ def test_iloc_mask(self):
916916
('index','.iloc') : 'iLocation based boolean indexing cannot use an indexable as a mask',
917917
('locs','') : 'Unalignable boolean Series key provided',
918918
('locs','.loc') : 'Unalignable boolean Series key provided',
919-
('locs','.iloc') : 'iLocation based boolean indexing cannot use an indexable as a mask',
919+
('locs','.iloc') : 'iLocation based boolean indexing on an integer type is not available',
920920
}
921921

922922
import warnings

0 commit comments

Comments
 (0)