-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
timedelta on datetime df, series arithmetic #59844
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
Conversation
@@ -997,6 +997,8 @@ def _make_na_block( | |||
dtype = interleaved_dtype([blk.dtype for blk in self.blocks]) | |||
if dtype is not None and np.issubdtype(dtype.type, np.floating): | |||
fill_value = dtype.type(fill_value) | |||
if dtype is not None and np.issubdtype(dtype.type, np.datetime64): | |||
fill_value = np.datetime64("NaT") |
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 also pass an appropriate unit to np.datetime64
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.
Thanks for the feedback! I was wondering what do you mean by unit?
tm.assert_frame_equal(result, expected) | ||
|
||
@pytest.mark.xfail(reason="NaT op NaT results in datetime instead of timedelta") | ||
def test_arithmetic_timestamp_timedelta(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.
IIUC these tests are mainly about the alignment behavior, so they belong in something like tests.frame.test_arithmetic
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.
The tests are currently in pandas/tests/frame/test_arithmetic.py. Should they be moved somewhere else?
@@ -1147,6 +1147,33 @@ def test_arithmetic_midx_cols_different_dtypes_different_order(self): | |||
expected = DataFrame([[-1, 1], [-1, 1]], columns=midx) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
@pytest.mark.xfail(reason="NaT op NaT results in datetime instead of timedelta") |
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.
@jbrockmendel in this test, the comparison fails because the result dtype value of NaT is datetime64 and expected dtype value of NaT is Timedelta. I would expect NaT - NaT to result in Timedelta. Is this behavior expected?
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.