File tree 3 files changed +11
-0
lines changed
3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,7 @@ Bug Fixes
476
476
477
477
- Bug in ``.style.bar`` may not rendered properly using specific browser (:issue:`11678`)
478
478
479
+ - Bug in rich comparison of ``Timedelta`` with a ``numpy.array`` of ``Timedelta``s that caused an infinite recursion (:issue:`11835`)
479
480
480
481
- Bug in ``df.replace`` while replacing value in mixed dtype ``Dataframe`` (:issue:`11698`)
481
482
Original file line number Diff line number Diff line change @@ -363,6 +363,14 @@ def test_compare_timedelta_series(self):
363
363
expected = pd .Series ([False , True ])
364
364
tm .assert_series_equal (actual , expected )
365
365
366
+ def test_compare_timedelta_ndarray (self ):
367
+ # GH11835
368
+ periods = [Timedelta ('0 days 01:00:00' ), Timedelta ('0 days 01:00:00' )]
369
+ arr = np .array (periods )
370
+ result = arr [0 ] > arr
371
+ expected = np .array ([False , False ])
372
+ self .assert_numpy_array_equal (result , expected )
373
+
366
374
def test_ops_notimplemented (self ):
367
375
class Other :
368
376
pass
Original file line number Diff line number Diff line change @@ -2184,6 +2184,8 @@ cdef class _Timedelta(timedelta):
2184
2184
raise TypeError (' Cannot compare type %r with type %r ' %
2185
2185
(type (self ).__name__,
2186
2186
type (other).__name__))
2187
+ if isinstance (other, np.ndarray):
2188
+ return PyObject_RichCompare(np.array([self ]), other, op)
2187
2189
return PyObject_RichCompare(other, self , _reverse_ops[op])
2188
2190
else :
2189
2191
if op == Py_EQ:
You can’t perform that action at this time.
0 commit comments