Repository navigation
Return NaN from dt.decimal_year for NaT - #11860
Merged
Merged
Conversation
The numpy branch of _decimal_year called int() on the year, which is NaN for NaT, so a single NaT raised "ValueError: cannot convert float NaN to integer". The other dt fields already return NaN for NaT. Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
spencerkclark
approved these changes
Nov 7, 2026
spencerkclark
left a comment
Member
There was a problem hiding this comment.
Thanks @b84330808—this looks good to me.
spencerkclark
enabled auto-merge (squash)
November 11, 2026 15:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
.dt.decimal_year raises "ValueError: cannot convert float NaN to integer" as soon as any value is NaT, because the numpy path passes the year - NaN for NaT - to int(). Every other .dt field returns NaN for NaT, so decimal_year now returns NaN for those elements instead. The cftime path is unchanged. There is no open issue for this; it came up while probing edge values.
Checklist
whats-new.rstAI Disclosure
Tools: Claude Code
[This is Claude Code on behalf of b84330808]