Skip to content

BUG: Timestamp.__richcmp__(dt64_unsupported_reso) #49104

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 1 commit into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ cdef class _Timestamp(ABCTimestamp):
elif other is NaT:
return op == Py_NE
elif is_datetime64_object(other):
ots = _Timestamp._from_dt64(other)
ots = Timestamp(other)
elif PyDateTime_Check(other):
if self.nanosecond == 0:
val = self.to_pydatetime()
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/scalar/timestamp/test_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@


class TestTimestampComparison:
def test_compare_non_nano_dt64(self):
# don't raise when converting dt64 to Timestamp in __richcmp__
dt = np.datetime64("1066-10-14")
ts = Timestamp(dt)

assert dt == ts

def test_comparison_dt64_ndarray(self):
ts = Timestamp("2021-01-01")
ts2 = Timestamp("2019-04-05")
Expand Down