Skip to content

Commit 62a626a

Browse files
junjunjunkKevin D Smith
authored and
Kevin D Smith
committed
TST: check inequality by comparing categorical with NaN ( pandas-dev#28384 ) (pandas-dev#36520)
1 parent 3015cf5 commit 62a626a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/arrays/categorical/test_missing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,24 @@ def test_use_inf_as_na_outside_context(self, values, expected):
148148
result = pd.isna(DataFrame(cat))
149149
expected = DataFrame(expected)
150150
tm.assert_frame_equal(result, expected)
151+
152+
@pytest.mark.parametrize(
153+
"a1, a2, categories",
154+
[
155+
(["a", "b", "c"], [np.nan, "a", "b"], ["a", "b", "c"]),
156+
([1, 2, 3], [np.nan, 1, 2], [1, 2, 3]),
157+
],
158+
)
159+
def test_compare_categorical_with_missing(self, a1, a2, categories):
160+
# GH 28384
161+
cat_type = CategoricalDtype(categories)
162+
163+
# !=
164+
result = Series(a1, dtype=cat_type) != Series(a2, dtype=cat_type)
165+
expected = Series(a1) != Series(a2)
166+
tm.assert_series_equal(result, expected)
167+
168+
# ==
169+
result = Series(a1, dtype=cat_type) == Series(a2, dtype=cat_type)
170+
expected = Series(a1) == Series(a2)
171+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)