Skip to content

BUG: disallow exotic np.datetime64 unit #61882

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
Jul 17, 2025

Conversation

jbrockmendel
Copy link
Member

This doesn't work locally for reasons described here. @seberg says it should work, so let's see if the CI can prove him right.

@@ -367,6 +369,13 @@ cdef _TSObject convert_to_tsobject(object ts, tzinfo tz, str unit,
if checknull_with_nat_and_na(ts):
obj.value = NPY_NAT
elif cnp.is_datetime64_object(ts):
num = (<PyDatetimeScalarObject*>obj).obmeta.num
Copy link
Contributor

@seberg seberg Jul 17, 2025

Choose a reason for hiding this comment

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

Suggested change
num = (<PyDatetimeScalarObject*>obj).obmeta.num
num = (<PyDatetimeScalarObject*>ts).obmeta.num

Took me embarrassingly long to spot :).

Copy link
Member Author

Choose a reason for hiding this comment

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

You're embarrassed? I'm the one who screwed it up in the first place!

@mroeschke mroeschke added this to the 3.0 milestone Jul 17, 2025
raise ValueError(
# GH#25611
"np.datetime64 objects with units containing a multiplier are "
"not supported", num
Copy link
Member

Choose a reason for hiding this comment

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

Is the num at the end here intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

that was for debugging, will update

@mroeschke mroeschke added the Datetime Datetime data dtype label Jul 17, 2025
@mroeschke mroeschke merged commit 6fca116 into pandas-dev:main Jul 17, 2025
43 checks passed
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bug-25611 branch July 17, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timestamp incorrectly handles datetime64 with exotic units
3 participants