Uh oh!
There was an error while loading. Please reload this page.
GH-45644: [Doc][Python] Document timezone loss when converting timestamp arrays to NumPy - #49843
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
34e5fadComparealex-anast
commented
Apr 23, 2026
Thanks for the review, @AlenkaF ! I've added a Unrelated, but the most recent commit also fixed the Sphinx doctest failures -- the |
AlenkaF
commented
Apr 23, 2026
I would use |
alex-anast
commented
Apr 24, 2026
@AlenkaFin the most recent iteration, I kept only what's necessary :) The final |
AlenkaF
left a comment
There was a problem hiding this comment.
Looking good, thank you for the updates!
One last thing I would like to bring up before we merge is the example of converting to NumPy through Pandas (to_pandas(timestamp_as_object=True).to_numpy()). I am undecided if this would be needed here or not, but am leaning towards yes. What do you think @alex-anast?
AlenkaF
commented
Apr 24, 2026
@github-actions crossbow submit preview-docs |
Revision: 7dcd9df Submitted crossbow builds: ursacomputing/crossbow @ actions-40c521d3da
|
alex-anast
commented
Apr 27, 2026
Thanks for the suggestion @AlenkaF ! |
AlenkaF
commented
May 4, 2026
@github-actions crossbow submit preview-docs |
Revision: cf094e6 Submitted crossbow builds: ursacomputing/crossbow @ actions-29ed4f5cc3
|
AlenkaF
left a comment
There was a problem hiding this comment.
Just one minor suggestion, otherwise LGTM, thanks!
https://s3.amazonaws.com/arrow-data/pr_docs/49843/python/numpy.html#timezone-aware-timestamps
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
After merging your PR, Conbench analyzed the 0 benchmarking runs that have been run so far on merge-commit 1fc0e19. None of the specified runs were found on the Conbench server. The full Conbench report has more details. |
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 1fc0e19. There were 3 benchmark results indicating a performance regression:
The full Conbench report has more details. It also includes information about 14 possible false positives for unstable benchmarks that are known to sometimes produce them. |
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 1fc0e19. There were 3 benchmark results indicating a performance regression:
The full Conbench report has more details. It also includes information about 14 possible false positives for unstable benchmarks that are known to sometimes produce them. |
…timestamp arrays to NumPy (apache#49843) ### Rationale for this change NumPy's `datetime64` type does not support timezones. When converting a timezone-aware Arrow timestamp array to NumPy via `to_numpy()`, the timezone information is silently dropped. This behaviour is expected but undocumented, which can surprise users (see apache#45644). ### What changes are included in this PR? Adds a "Timezone-aware Timestamps" subsection to `docs/source/python/numpy.rst` that: - Explains the timezone loss when calling `to_numpy()` on tz-aware timestamp arrays - Shows a code example demonstrating the behavior - Documents two alternatives: `to_pandas()` for tz-aware Series, and `to_pylist()` for Python `datetime` objects with `tzinfo` ### Are these changes tested? Documentation-only change. All code examples were verified against pyarrow 24.0.0 and `sphinx-lint` passes 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. * GitHub Issue: apache#45644Closesapache#45644 Authored-by: Alexandros Anastasiou <anastasioyaa@gmail.com> Signed-off-by: AlenkaF <frim.alenka@gmail.com>
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