-
Notifications
You must be signed in to change notification settings - Fork 915
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
Support round operation on datetime64[ns] datatypes #9820
Support round operation on datetime64[ns] datatypes #9820
Conversation
rerun tests |
…into branch-22.02
Co-authored-by: Bradley Dice <[email protected]>
…into branch-22.02
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 changeset looks good to me, thanks for iterating on this @mayankanand007! I think there are some opportunities to consolidate the public C++ API and Cython bindings. I will file an issue documenting my proposal when I get a chance. The summary is that I'd like to replace all the variations of round_day(column)
, ceil_hour(column)
, floor_microsecond(column)
with round(column, freq)
, ceil(column, freq)
, or floor(column, freq)
where freq
is a public enum of supported rounding frequencies.
I'd like to see less boilerplate code repeated between ceil/floor/round in the tests (both Python and C++). I am approving because the new tests for round are aligned with the existing ceil/floor tests. A refactor could be done later.
rerun 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.
I have a couple of small comments, but otherwise this looks good! I'll hold off on final approval pending @shwina's thoughts on the parameter name change.
Co-authored-by: Vyas Ramasubramani <[email protected]>
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.
LGTM. @mayankanand007 you'll need to fix the style checks, but I assume that the tests will pass after.
Thanks @vyasr ! the style failure is due to a known issue (#9870), waiting for that to get merged. Does this PR need more approvals? |
@gpucibot merge |
This PR is a follow up to #9820 where @bdice and @vyasr raised the point of having a design such that we avoid writing bunch of boilerplate code, which is common in the implementations of ceil/round/floor. The aim is to reduce the total number of functions, as well as have a cleaner design. Authors: - Mayank Anand (https://github.com/mayankanand007) Approvers: - Ashwin Srinath (https://github.com/shwina) - Karthikeyan (https://github.com/karthikeyann) - Bradley Dice (https://github.com/bdice) URL: #9926
This PR fixes #9652, by adding support for doing
round
operation ondtaetime64[ns]
types, which is essentially supportingseries.dt.round
andDatetimeIndex.round
.In addition to this, we move the round implementation that is currently there from
Frame
toIndexedFrame
aspd.Index
doesn't supportround
. This is why we move this implementation toIndexedFrame
, and add the code specifically forDatetimeIndex
(for this PR), so as to avoid having a round method for another index types.