Skip to content

Commit fa13416

Browse files
committed
Work in progress before switching branch
1 parent 8295e19 commit fa13416

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/core/indexing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,25 @@ def _setitem_with_indexer(self, indexer, value, name: str = "iloc") -> None:
17961796
since it goes from positional indexers back to labels when calling
17971797
BlockManager methods, see GH#12991, GH#22046, GH#15686.
17981798
"""
1799+
1800+
def _has_missing_in_indexer(indexer) -> bool:
1801+
# If the indexer is a list or tuple, check for None directly
1802+
if isinstance(indexer, (list, tuple)):
1803+
return any(x is None for x in indexer)
1804+
1805+
# If the indexer is a NumPy, Pandas, or Arrow array-like, try safe casting
1806+
try:
1807+
# Some extension types may not support direct iteration
1808+
indexer_list = indexer.tolist()
1809+
return any(x is None for x in indexer_list)
1810+
except Exception:
1811+
return False
1812+
1813+
if _has_missing_in_indexer(indexer):
1814+
raise ValueError(
1815+
"Cannot index with an integer indexer containing NA values"
1816+
)
1817+
17991818
info_axis = self.obj._info_axis_number
18001819

18011820
# maybe partial set

0 commit comments

Comments
 (0)