GH-45644: [Doc][Python] Document timezone loss when converting timestamp arrays to NumPy#49843
GH-45644: [Doc][Python] Document timezone loss when converting timestamp arrays to NumPy#49843alex-anast wants to merge 2 commits intoapache:mainfrom
Conversation
…timestamp arrays to NumPy
|
|
|
|
AlenkaF
left a comment
There was a problem hiding this comment.
Thank you for the PR, the change looks good to me!
One ask I have is to include the caveat when using to_pandas() in the case of nested types described in #41162 (works for structs and maps, not for lists; unions and list views would need to be checked).
956b6a6 to
34e5fad
Compare
|
Thanks for the review, @AlenkaF ! I've added a Unrelated, but the most recent commit also fixed the Sphinx doctest failures -- the |
I would use |
Rationale for this change
NumPy's
datetime64type does not support timezones. When converting a timezone-aware Arrow timestamp array to NumPy viato_numpy(), the timezone information is silently dropped. This behaviour is expected but undocumented, which can surprise users (see #45644).What changes are included in this PR?
Adds a "Timezone-aware Timestamps" subsection to
docs/source/python/numpy.rstthat:to_numpy()on tz-aware timestamp arraysto_pandas()for tz-aware Series, andto_pylist()for Pythondatetimeobjects withtzinfoAre these changes tested?
Documentation-only change. All code examples were verified against pyarrow 24.0.0 and
sphinx-lintpasses clean.Are there any user-facing changes?
No behaviour changes. This adds documentation for existing behaviour.
AI-generated code disclosure
This PR was developed with assistance from an AI coding tool (Claude, Anthropic). All changes have been reviewed, understood, and verified.
to_numpy#45644Closes [Doc][Python] Timestamp with tz loses its time zone after
to_numpy#45644