Skip to content

Conversation

sukriti1
Copy link
Contributor

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")
Copy link
Member

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

Copy link
Contributor Author

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):
Copy link
Member

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

Copy link
Contributor Author

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?

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")
Copy link
Contributor Author

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?

@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: subtracting datetime series from datetime dataframe, or datetime dataframe from datetime series, raises TypeError or UFuncTypeError
3 participants