-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Fix Series.__sub__ non-nano datetime64 #18783
Changes from 3 commits
96c45f9
53de7b5
4e32e7f
9480e3a
aa57961
61afacc
3992f30
4e0688c
26a1ad6
b5c16f9
b0ad140
36eb181
0dbe62c
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 |
---|---|---|
|
@@ -28,6 +28,31 @@ | |
from .common import TestData | ||
|
||
|
||
class TestDatetimeLikeArithmetic(object): | ||
def test_sub_datetime64_not_ns(self): | ||
# GH#7996 | ||
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. parameterize this |
||
ser = Series(date_range('20130101', periods=3)) | ||
dt64 = np.datetime64('2013-01-01') | ||
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. test with a tz-aware as well (as I think that may hit your path, unless its getting caught earlier) 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. It gets caught earlier: tz compat raises ValueError in ops._validate |
||
assert dt64.dtype == 'datetime64[D]' | ||
res = ser - dt64 | ||
expected = pd.Series([Timedelta(days=0), Timedelta(days=1), | ||
Timedelta(days=2)]) | ||
tm.assert_series_equal(res, expected) | ||
|
||
res = dt64 - ser | ||
tm.assert_series_equal(res, -expected) | ||
|
||
# check for DatetimeIndex and DataFrame while we're at it | ||
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. make the comment relevant |
||
dti = pd.DatetimeIndex(ser) | ||
res = dti - dt64 | ||
tm.assert_index_equal(res, pd.Index(expected)) | ||
|
||
res = dt64 - dti | ||
tm.assert_index_equal(res, pd.Index(-expected)) | ||
|
||
# TODO: This is still broken for ser.to_frame() | ||
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. then if you want to add a test with an xfail would be helpful. (and an issue reference), TODO's are only so good. |
||
|
||
|
||
class TestSeriesOperators(TestData): | ||
|
||
def test_series_comparison_scalars(self): | ||
|
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.
pls don't add extraneous things