Skip to content

Commit 7f1b385

Browse files
committed
NA membership should return False
1 parent e47a86d commit 7f1b385

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pandas/core/arrays/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def __contains__(self, item) -> bool:
361361
# comparisons of any item to pd.NA always return pd.NA, so e.g. "a" in [pd.NA]
362362
# would raise a TypeError. The implementation below works around that.
363363
if isna(item):
364-
return isna(self).any() if self._can_hold_na else False
364+
return False
365365
else:
366366
return (item == self).any()
367367

pandas/tests/arrays/categorical/test_operators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,4 @@ def test_contains(self, ordered):
406406
cat = Categorical([np.nan, "a"], ordered=ordered)
407407
assert "a" in cat
408408
assert "x" not in cat
409-
assert pd.NA in cat
409+
assert pd.NA not in cat

0 commit comments

Comments
 (0)