Skip to content

Commit d25b169

Browse files
authored
BUG: Datetimelike equality comparisons with Categorical (#38986)
1 parent c509095 commit d25b169

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/arrays/test_datetimelike.py

+14
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ def test_compare_len1_raises(self):
8585
with pytest.raises(ValueError, match="Lengths must match"):
8686
idx <= idx[[0]]
8787

88+
@pytest.mark.parametrize(
89+
"result",
90+
[
91+
pd.date_range("2020", periods=3),
92+
pd.date_range("2020", periods=3, tz="UTC"),
93+
pd.timedelta_range("0 days", periods=3),
94+
pd.period_range("2020Q1", periods=3, freq="Q"),
95+
],
96+
)
97+
def test_compare_with_Categorical(self, result):
98+
expected = pd.Categorical(result)
99+
assert all(result == expected)
100+
assert not any(result != expected)
101+
88102
@pytest.mark.parametrize("reverse", [True, False])
89103
@pytest.mark.parametrize("as_index", [True, False])
90104
def test_compare_categorical_dtype(self, arr1d, as_index, reverse, ordered):

0 commit comments

Comments
 (0)