-
-
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
DateOffset add to ndarray #57927
DateOffset add to ndarray #57927
Conversation
if other.dtype == object: | ||
return np.array([self + x for x in other]) | ||
elif is_datetime64_any_dtype(other): | ||
return self._apply_array(other).astype(other.dtype) |
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.
Do we need the astype here?
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.
I found that without this DateOffset._apply_array did not respect the dtype that was passed in
once the .astype step was added in, I could use e.g. datetime64[D] and get a datetime64[D] back
I'll do some further testing when working on unit tests
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.
FWIW datetime64[D]
is not a supported unit in pandas
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.
This would also need tests and a whatsnew note in v3.0.0.rst
Co-authored-by: Matthew Roeschke <[email protected]>
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
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. |
This is WIP to implement changes needed to allow DateOffset subclasses e.g. MonthEnd to be directly added to numpy.ndarray, e.g.
numpy.array(['2022-01-01'], dtype='datetime64') + pandas.offsets.MonthEnd(1)
I need some guidance on:
Many thanks!
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.