diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index e40318bd65db2..744f1e14533e7 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -423,10 +423,10 @@ Conversion - Bug in :class:`WeekOfMonth` and :class:`LastWeekOfMonth` where default keyword arguments for constructor raised ``ValueError`` (:issue:`19142`) - Bug in localization of a naive, datetime string in a ``Series`` constructor with a ``datetime64[ns, tz]`` dtype (:issue:`174151`) - :func:`Timestamp.replace` will now handle Daylight Savings transitions gracefully (:issue:`18319`) - - - +- +- - Bug in ``.astype()`` to non-ns timedelta units would hold the incorrect dtype (:issue:`19176`, :issue:`19223`, :issue:`12425`) +- Bug in subtracting :class:`Series` from ``NaT`` incorrectly returning ``NaT`` (:issue:`19158`) Indexing diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 683be4c9aa3a8..39f9437f0cecf 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -156,7 +156,7 @@ cdef class _NaT(datetime): neg_other = -other return self + neg_other - elif getattr(other, '_typ', None) in ['period', + elif getattr(other, '_typ', None) in ['period', 'series', 'periodindex', 'dateoffset']: return NotImplemented diff --git a/pandas/tests/scalar/test_nat.py b/pandas/tests/scalar/test_nat.py index 73e8c783ba882..a6b217a37bd0c 100644 --- a/pandas/tests/scalar/test_nat.py +++ b/pandas/tests/scalar/test_nat.py @@ -314,8 +314,7 @@ def test_nat_arithmetic_index(): @pytest.mark.parametrize('box, assert_func', [ (TimedeltaIndex, tm.assert_index_equal), - pytest.param(Series, tm.assert_series_equal, - marks=pytest.mark.xfail(reason='NaT - Series returns NaT')) + (Series, tm.assert_series_equal) ]) def test_nat_arithmetic_td64_vector(box, assert_func): # GH#19124