BUG: to_json(orient="table") drops fixed-offset timezone (GH#39537)#66016
Draft
jbrockmendel wants to merge 1 commit into
Draft
BUG: to_json(orient="table") drops fixed-offset timezone (GH#39537)#66016jbrockmendel wants to merge 1 commit into
jbrockmendel wants to merge 1 commit into
Conversation
A column with a fixed-offset stdlib timezone (e.g. timezone(timedelta(hours=1))) was silently serialized without its tz in the table schema, so the offset was lost on round-trip through read_json. Emit the round-trippable "UTC+HH:MM" string instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
closes #39537
A column with a fixed-offset stdlib timezone (e.g.
datetime.timezone(timedelta(hours=1)), dtypedatetime64[ns, UTC+01:00]) was silently serialized without itstzin the table schema. The originalAttributeErrorfrom GH-39537 was already fixed, but the fix'sisinstance(zone, str)guard skipped fixed-offsetdatetime.timezoneobjects (whichget_timezonereturns as-is rather than as a string), so the offset was dropped and lost on round-trip throughread_json.Now emit
str(zone)for these, giving the round-trippable"UTC+HH:MM"form (the same stringDatetimeTZDtype.__str__uses andmaybe_get_tzalready parses).