-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
BUG: Fix dt64[non_nano] + some_offsets incorrectly rounding #62383
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
|
@@ -817,7 +817,16 @@ def _add_offset(self, offset: BaseOffset) -> Self: | |
result = type(self)._from_sequence(res_values, dtype=self.dtype) | ||
|
||
else: | ||
result = type(self)._simple_new(res_values, dtype=res_values.dtype) | ||
units = ["ns", "us", "ms", "s", "m", "h", "D"] | ||
res_unit = self.unit | ||
if hasattr(offset, "offset"): | ||
offset_unit = Timedelta(offset.offset).unit | ||
idx_self = units.index(self.unit) | ||
idx_offset = units.index(offset_unit) | ||
res_unit = units[min(idx_self, idx_offset)] | ||
dtype = tz_to_dtype(self.tz, unit=res_unit) | ||
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. wont you need to cast res_values before calling simple_new? 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. yes, thanks! . Should we wrap this in 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. i suspect that The Right Way to do this would be to find the correct dtype before calling _from_sequence on L817 and pass it there |
||
result = type(self)._simple_new(res_values, dtype=dtype) | ||
|
||
if offset.normalize: | ||
result = result.normalize() | ||
result._freq = None | ||
|
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.
are m, h, D possible?
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.
No, I'm wrong I will update this .