Skip to content

Commit 4ebdc50

Browse files
jbrockmendeljreback
authored andcommitted
Fix pd.NaT - Series (#19251)
1 parent c271d4d commit 4ebdc50

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

doc/source/whatsnew/v0.23.0.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,10 @@ Conversion
423423
- Bug in :class:`WeekOfMonth` and :class:`LastWeekOfMonth` where default keyword arguments for constructor raised ``ValueError`` (:issue:`19142`)
424424
- Bug in localization of a naive, datetime string in a ``Series`` constructor with a ``datetime64[ns, tz]`` dtype (:issue:`174151`)
425425
- :func:`Timestamp.replace` will now handle Daylight Savings transitions gracefully (:issue:`18319`)
426-
427-
428-
426+
-
427+
-
429428
- Bug in ``.astype()`` to non-ns timedelta units would hold the incorrect dtype (:issue:`19176`, :issue:`19223`, :issue:`12425`)
429+
- Bug in subtracting :class:`Series` from ``NaT`` incorrectly returning ``NaT`` (:issue:`19158`)
430430

431431

432432
Indexing

pandas/_libs/tslibs/nattype.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ cdef class _NaT(datetime):
156156
neg_other = -other
157157
return self + neg_other
158158

159-
elif getattr(other, '_typ', None) in ['period',
159+
elif getattr(other, '_typ', None) in ['period', 'series',
160160
'periodindex', 'dateoffset']:
161161
return NotImplemented
162162

pandas/tests/scalar/test_nat.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ def test_nat_arithmetic_index():
314314

315315
@pytest.mark.parametrize('box, assert_func', [
316316
(TimedeltaIndex, tm.assert_index_equal),
317-
pytest.param(Series, tm.assert_series_equal,
318-
marks=pytest.mark.xfail(reason='NaT - Series returns NaT'))
317+
(Series, tm.assert_series_equal)
319318
])
320319
def test_nat_arithmetic_td64_vector(box, assert_func):
321320
# GH#19124

0 commit comments

Comments
 (0)