Skip to content

Commit eb2ff31

Browse files
authored
BUG: Timestamp.__richcmp__(dt64_unsupported_reso) (pandas-dev#49104)
1 parent fbff58f commit eb2ff31

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pandas/_libs/tslibs/timestamps.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ cdef class _Timestamp(ABCTimestamp):
324324
elif other is NaT:
325325
return op == Py_NE
326326
elif is_datetime64_object(other):
327-
ots = _Timestamp._from_dt64(other)
327+
ots = Timestamp(other)
328328
elif PyDateTime_Check(other):
329329
if self.nanosecond == 0:
330330
val = self.to_pydatetime()

pandas/tests/scalar/timestamp/test_comparisons.py

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212

1313

1414
class TestTimestampComparison:
15+
def test_compare_non_nano_dt64(self):
16+
# don't raise when converting dt64 to Timestamp in __richcmp__
17+
dt = np.datetime64("1066-10-14")
18+
ts = Timestamp(dt)
19+
20+
assert dt == ts
21+
1522
def test_comparison_dt64_ndarray(self):
1623
ts = Timestamp("2021-01-01")
1724
ts2 = Timestamp("2019-04-05")

0 commit comments

Comments
 (0)