-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: Timestamp.normalize()
can overflow silently
#60583
Comments
Timestamp.normalize()
Timestamp.normalize()
can overflow silently (vs .floor()
which raises)
I don't think the above mention is a bug. The reason is because- |
@shashankrushiya I'm not following. How does that mean it's not a bug?
So then why doesn't BTW, note that |
Timestamp.normalize()
can overflow silently (vs .floor()
which raises)Timestamp.normalize()
can overflow silently
Thanks for the report! Agreed normalize should raise an OverflowError here. PRs to fix are welcome!
I view this as a violation of pandas' Code of conduct and ask you to refrain from making such statements in the future. We'd like to make pandas a welcome place for all contributors, and this type of comment works against this goal. |
@rhshadrach My bad. I've edited my above comment to be respectful and more constructive. Sorry @shashankrushiya! |
take |
Proposing a change to fix this issue: #60624. My understanding is that the bug is due to the code logic described in timestamps.pyx. The first option that I considered was modifying normalize in timestamps.pyx. The second option that I considered was modifying normalize_i8_stamp() in timestamps.pyx, and also updating normalize_i8_stamp() in timestamps.pxd to update the normalize_i8_stamp() declaration to match the new signature. datetimes.py would not be modified because my understanding is that this overflow issue is not present in datetimes. |
Pandas version checks
is:issue normalize overflow
Issue description
I was trying to get the minimum date, so I tried
pd.Timestamp.min.normalize()
before realizing that would be out of range, but what's weird is that it overflows without warning:For reference:
Compare that to
.floor('D')
, which I thought would be equivalent, but it raises:as well as
.round('D')
(same error).Sidenote: What I really wanted was
.ceil('D')
, which gets the first whole day:Installed Versions
The text was updated successfully, but these errors were encountered: