Skip to content
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

BUG: cut with non-nano #56101

Merged
merged 12 commits into from
Dec 1, 2023
Merged

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.

sits on top of #56099

@mroeschke mroeschke added cut cut, qcut Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Nov 22, 2023
# TODO: constructing DatetimeIndex with dtype="M8[s]" without truncating
# the first entry here raises in array_to_datetime. Should truncate
# instead of raising?
# TODO: should we truncate to 7 seconds or 8?
Copy link
Member

Choose a reason for hiding this comment

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

If these are inclusive, left bin edge and in nanos the result was 7.2, I think I would expect 7 instead of 8

Copy link
Member Author

Choose a reason for hiding this comment

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

looking at this closer, i think it doesn't really matter bc bins[0] is calculated roughly on min(data) - .001 * (max(data) - min(data)). that .001 * [...] adjustment looks intended to make sure that the bottom bin is a strict lower bound. Exactly how strict doesn't seem to matter. In this test case, max(data) - min(data) is a 2-day Timedelta, and when that Timedelta has second unit, multiplying it by .001 truncated to Timedelta(minutes=2, seconds=52), truncating the .8 seconds.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I forgot about the 0.001 offset applied to the edges (though it seem code-smelly). The current truncation result should be OK then

@mroeschke mroeschke added this to the 2.2 milestone Dec 1, 2023
@mroeschke mroeschke merged commit 65af776 into pandas-dev:main Dec 1, 2023
44 checks passed
@mroeschke
Copy link
Member

Thanks @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cut cut, qcut Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants