From cc4ec15d5ed18c54b01c1e16f0fffe4ca3f6c6bc Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Tue, 9 Jan 2018 17:07:36 -0800 Subject: [PATCH 1/3] fix 19158 --- doc/source/whatsnew/v0.23.0.txt | 2 +- pandas/_libs/tslibs/nattype.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 9f4e3e3ac624f..082dcb1ae29c5 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -377,7 +377,7 @@ Conversion - Fixed bug where comparing :class:`DatetimeIndex` failed to raise ``TypeError`` when attempting to compare timezone-aware and timezone-naive datetimelike objects (:issue:`18162`) - Bug in :class:`DatetimeIndex` where the repr was not showing high-precision time values at the end of a day (e.g., 23:59:59.999999999) (:issue:`19030`) - Bug where dividing a scalar timedelta-like object with :class:`TimedeltaIndex` performed the reciprocal operation (:issue:`19125`) -- +- 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 From c0a39dfa8dc98cff0422390ed50596d583da6830 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 15 Jan 2018 12:30:37 -0800 Subject: [PATCH 2/3] restore whitespace --- doc/source/whatsnew/v0.23.0.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 16b4b06f546c4..ed118212b53be 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -386,8 +386,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 subtracting :class:`Series` from ``NaT`` incorrectly returning ``NaT`` (:issue:`19158`) +- +- - 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 From dbb2a8213db6e181647257680fbac7ae58cdce9d Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 15 Jan 2018 16:37:29 -0800 Subject: [PATCH 3/3] un-xfail test now that #19139 is merged --- pandas/tests/scalar/test_nat.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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