Skip to content

Commit c789abd

Browse files
Switch to KeyError pt.2
1 parent 60c44ff commit c789abd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/core/indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ def convert_missing_indexer(indexer):
23712371
indexer = indexer["key"]
23722372

23732373
if isinstance(indexer, bool):
2374-
raise TypeError("cannot use a single bool to index into setitem")
2374+
raise KeyError("cannot use a single bool to index into setitem")
23752375
return indexer, True
23762376

23772377
return indexer, False

pandas/tests/frame/indexing/test_indexing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,9 +954,9 @@ def test_getitem_setitem_ix_bool_keyerror(self):
954954
df.loc[True]
955955

956956
msg = "cannot use a single bool to index into setitem"
957-
with pytest.raises(TypeError, match=msg):
957+
with pytest.raises(KeyError, match=msg):
958958
df.loc[False] = 0
959-
with pytest.raises(TypeError, match=msg):
959+
with pytest.raises(KeyError, match=msg):
960960
df.loc[True] = 0
961961

962962
# TODO: rename? remove?

0 commit comments

Comments
 (0)