Skip to content

BUG: Datetimelike equality comparisons with Categorical #38986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 8, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ def _compare_other(self, s, data, op_name, other):
# with (some) integers, depending on the value.
pass

def test_compare_with_Categorical(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you parameterize this over the types (date_range and such),

also pls add a case for !=

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't add additional tests to this file (some other files in this directory have a note about that, just opened a PR to add that to this file as well -> #39003)

@ftrihardjo can you move the test to eg /tests/arrays/test_datetimelike.py ? (not fully sure what is the best place to put those nowadays) There also already seems to be a test_compare_categorical_dtype test in that file, so you can put it close to that one (or see to what extent it overlaps)

result = pd.date_range("2020", periods=3)
expected = pd.Categorical(result)
assert all(result == expected)
result = pd.date_range("2020", periods=3, tz="UTC")
expected = pd.Categorical(result)
assert all(result == expected)
result = pd.timedelta_range("0 days", periods=3)
expected = pd.Categorical(result)
assert all(result == expected)
result = pd.period_range("2020Q1", periods=3, freq="Q")
expected = pd.Categorical(result)
assert all(result == expected)


class TestMissing(BaseDatetimeTests, base.BaseMissingTests):
pass
Expand Down