-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
BUG: fix Series[timedelta64] arithmetic with Timedelta scalars #18831
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 5 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 |
---|---|---|
|
@@ -976,16 +976,27 @@ 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])) | ||
|
||
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])) | ||
# TODO: the Timedelta // td1 fails because of a bug | ||
# in Timedelta.__floordiv__, see GH#18824 | ||
# tm.assert_series_equal(tdscalar // td1, Series([1, 1, 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.
don't put things in Other. This is conversion. Also note that a floordiv of scalar / Series was incorrect before.
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.
verify that we have a doc example in timedelta.rst 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.
Something other than the mention of
Series.__rfloordiv__
?