-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Make TimedeltaIndex +/- pd.NaT return TimedeltaIndex #19139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
cc01bd5
6eec080
eed99f4
0fdd795
aacad9c
5b5547b
4fd98e4
5a54a92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,14 +302,30 @@ def test_nat_arithmetic_index(): | |
tm.assert_index_equal(left - right, exp) | ||
tm.assert_index_equal(right - left, exp) | ||
|
||
# timedelta | ||
# timedelta # GH#19124 | ||
tdi = TimedeltaIndex(['1 day', '2 day'], name='x') | ||
exp = DatetimeIndex([NaT, NaT], name='x') | ||
for (left, right) in [(NaT, tdi)]: | ||
tm.assert_index_equal(left + right, exp) | ||
tm.assert_index_equal(right + left, exp) | ||
tm.assert_index_equal(left - right, exp) | ||
tm.assert_index_equal(right - left, exp) | ||
tdi_nat = TimedeltaIndex([NaT, NaT], name='x') | ||
|
||
tm.assert_index_equal(tdi + NaT, tdi_nat) | ||
tm.assert_index_equal(NaT + tdi, tdi_nat) | ||
tm.assert_index_equal(tdi - NaT, tdi_nat) | ||
tm.assert_index_equal(NaT - tdi, tdi_nat) | ||
|
||
|
||
@pytest.mark.xfail(reason='NaT - Series returns NaT. This behavior was ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you just parametrize around tdi and Series, too much repeated code (you can xfail that case using pytest.param) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls do this here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are pinging but not doing what I ask. |
||
'introduced somewhere between 0.22.0 and ' | ||
'23fb3392adedd3a') | ||
def test_nat_arithmetic_series(): | ||
# GH#19124 | ||
tdi = TimedeltaIndex(['1 day', '2 day'], name='x') | ||
tdi_nat = TimedeltaIndex([NaT, NaT], name='x') | ||
ser = Series(tdi) | ||
ser_nat = Series(tdi_nat) | ||
|
||
tm.assert_series_equal(ser + NaT, ser_nat) | ||
tm.assert_series_equal(NaT + ser, ser_nat) | ||
tm.assert_series_equal(ser - NaT, ser_nat) | ||
tm.assert_series_equal(NaT - ser, ser_nat) | ||
|
||
|
||
def test_nat_pinned_docstrings(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add similar testing for Series here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoot this surfaces a new bug; I'll xfail for now.