File tree 3 files changed +5
-2
lines changed
3 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ Backwards incompatible API changes
40
40
Other API Changes
41
41
^^^^^^^^^^^^^^^^^
42
42
43
+ - ``NaT`` division with :class:`datetime.timedelta` will now return ``NaN`` instead of raising (:issue:`17876`)
43
44
- :class:`Timestamp` will no longer silently ignore unused or invalid `tz` or `tzinfo` arguments (:issue:`17690`)
44
45
-
45
46
-
Original file line number Diff line number Diff line change @@ -1448,15 +1448,15 @@ _nat_scalar_rules[Py_GE] = False
1448
1448
1449
1449
1450
1450
cdef _nat_divide_op(self , other):
1451
- if (isinstance (other, Timedelta ) or
1451
+ if (PyDelta_Check (other) or
1452
1452
is_timedelta64_object(other) or other is NaT):
1453
1453
return np.nan
1454
1454
if is_integer_object(other) or is_float_object(other):
1455
1455
return NaT
1456
1456
return NotImplemented
1457
1457
1458
1458
cdef _nat_rdivide_op(self , other):
1459
- if isinstance (other, Timedelta ):
1459
+ if PyDelta_Check (other):
1460
1460
return np.nan
1461
1461
return NotImplemented
1462
1462
Original file line number Diff line number Diff line change @@ -248,6 +248,8 @@ def test_nat_arithmetic():
248
248
assert left + right is NaT
249
249
assert right - left is NaT
250
250
assert left - right is NaT
251
+ assert np .isnan (left / right )
252
+ assert np .isnan (right / left )
251
253
252
254
# GH 11718
253
255
t_utc = Timestamp ('2014-01-01' , tz = 'UTC' )
You can’t perform that action at this time.
0 commit comments