-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
BUG: fix Series[timedelta64] arithmetic with Timedelta scalars #18831
Changes from 7 commits
1eab96f
25071a8
45c7260
95cc5f9
6ff2d5f
4fe8f74
4821f05
10054de
66561ef
347a221
8789be7
c3795d0
ef8d6e2
2b3484f
3250913
3a5c3b5
729d240
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 |
---|---|---|
|
@@ -962,6 +962,14 @@ def test_timedelta64_ops_nat(self): | |
|
||
|
||
class TestDatetimeSeriesArithmetic(object): | ||
@pytest.mark.xfail(reason='GH#18824 bug in Timedelta.__floordiv__') | ||
def test_timedelta_rfloordiv(self): | ||
td1 = Series([timedelta(minutes=5, seconds=3)] * 3) | ||
td1.iloc[2] = np.nan | ||
tdscalar = Timedelta(minutes=5, seconds=4) | ||
tm.assert_series_equal(tdscalar // td1, | ||
Series([1, 1, np.nan])) | ||
|
||
def test_operators_datetimelike(self): | ||
def run_ops(ops, get_ser, test_ser): | ||
|
||
|
@@ -976,16 +984,24 @@ def run_ops(ops, get_ser, test_ser): | |
# ## timedelta64 ### | ||
td1 = Series([timedelta(minutes=5, seconds=3)] * 3) | ||
td1.iloc[2] = np.nan | ||
td2 = timedelta(minutes=5, seconds=4) | ||
ops = ['__mul__', '__floordiv__', '__pow__', '__rmul__', | ||
'__rfloordiv__', '__rpow__'] | ||
run_ops(ops, td1, td2) | ||
td1 + td2 | ||
td2 + td1 | ||
td1 - td2 | ||
td2 - td1 | ||
td1 / td2 | ||
td2 / td1 | ||
tdscalar = Timedelta(minutes=5, seconds=4) | ||
ops = ['__mul__', '__pow__', '__rmul__', '__rpow__'] | ||
run_ops(ops, td1, tdscalar) | ||
td1 + tdscalar | ||
tdscalar + td1 | ||
td1 - tdscalar | ||
tdscalar - td1 | ||
td1 / tdscalar | ||
tdscalar / td1 | ||
tm.assert_series_equal(td1 // tdscalar, Series([0, 0, np.nan])) | ||
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 parametrize these last ones they seem pretty similar 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. This is part of a 127 line test that is all over the place. I'd prefer to clean it up in a follow-up. 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. ok, this needs parameterization / refactor, but can follow up. |
||
tm.assert_series_equal(td1 // tdscalar.to_pytimedelta(), | ||
Series([0, 0, np.nan])) | ||
tm.assert_series_equal(td1 // tdscalar.to_timedelta64(), | ||
Series([0, 0, np.nan])) | ||
tm.assert_series_equal(tdscalar.to_pytimedelta() // td1, | ||
Series([1, 1, np.nan])) | ||
tm.assert_series_equal(tdscalar.to_timedelta64() // td1, | ||
Series([1, 1, np.nan])) | ||
|
||
# ## datetime64 ### | ||
dt1 = Series([Timestamp('20111230'), Timestamp('20120101'), | ||
|
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.
is this the right issue?
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.
AFAIK there is no dedicated issue. I made a checkbox for this in 18224.
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.
don't mark 18224, its way to big to figure out what you are talking about (you can certainly reference this PR which is I think what you are doing). rather list the PR number (if there isn't an issue). do this generally.