Skip to content

Commit dd01ed1

Browse files
committed
NA membership should return False
1 parent 807b5ed commit dd01ed1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pandas/core/arrays/base.py

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

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

pandas/tests/arrays/string_/test_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,4 @@ def test_contains():
358358
arr = pd.arrays.StringArray(np.array(["a", pd.NA]))
359359
assert "a" in arr
360360
assert "x" not in arr
361-
assert pd.NA in arr
361+
assert pd.NA not in arr

0 commit comments

Comments
 (0)