Skip to content

ENH: Timedelta/Timestamp round support non-nano #47356

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

Merged
merged 5 commits into from
Jun 16, 2022

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@@ -1932,7 +1932,8 @@ def _round(self, freq, mode, ambiguous, nonexistent):

values = self.view("i8")
values = cast(np.ndarray, values)
nanos = to_offset(freq).nanos
nanos = to_offset(freq).nanos # raises on non-fixed frequencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests that trigger the raising behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@@ -148,11 +148,13 @@ def test_round_minute_freq(self, test_input, freq, expected, rounder):
result = func(freq)
assert result == expected

def test_ceil(self):
dt = Timestamp("20130101 09:10:11")
@pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you parameterize test_ceil below too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, updated

@mroeschke mroeschke added this to the 1.5 milestone Jun 16, 2022
@mroeschke mroeschke added Datetime Datetime data dtype Timedelta Timedelta data type Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Jun 16, 2022
@mroeschke mroeschke merged commit c6e7d8d into pandas-dev:main Jun 16, 2022
@jbrockmendel jbrockmendel deleted the nano-round branch June 16, 2022 01:19
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
* ENH: Timedelta/Timestamp round support non-nano

* parametrize test_floor

* un-xfail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Non-Nano datetime64/timedelta64 with non-nanosecond resolution Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants