Skip to content

BUG: to_json(orient="table") drops fixed-offset timezone (GH#39537)#66016

Draft
jbrockmendel wants to merge 1 commit into
pandas-dev:mainfrom
jbrockmendel:bug-39537
Draft

BUG: to_json(orient="table") drops fixed-offset timezone (GH#39537)#66016
jbrockmendel wants to merge 1 commit into
pandas-dev:mainfrom
jbrockmendel:bug-39537

Conversation

@jbrockmendel

Copy link
Copy Markdown
Member

closes #39537

A column with a fixed-offset stdlib timezone (e.g. datetime.timezone(timedelta(hours=1)), dtype datetime64[ns, UTC+01:00]) was silently serialized without its tz in the table schema. The original AttributeError from GH-39537 was already fixed, but the fix's isinstance(zone, str) guard skipped fixed-offset datetime.timezone objects (which get_timezone returns as-is rather than as a string), so the offset was dropped and lost on round-trip through read_json.

Now emit str(zone) for these, giving the round-trippable "UTC+HH:MM" form (the same string DatetimeTZDtype.__str__ uses and maybe_get_tz already parses).

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>
@jbrockmendel jbrockmendel added Bug IO JSON read_json, to_json, json_normalize Timezones Timezone data dtype labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug IO JSON read_json, to_json, json_normalize Timezones Timezone data dtype

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when converting df to json table (utc timezone date time object causes the error)

1 participant