GH-45644: Documentation Timestamp with tz loses its time zone after to_numpy #47681
+21
−0
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.
DOC: clarify that Array.to_numpy() drops timezone for timestamp arrays (fixes #45644)
Rationale for this change
NumPy's
datetime64
dtype does not preserve timezone metadata.Currently, when converting Arrow timestamp arrays with a timezone (e.g.
timestamp[s, tz=UTC]
) via.to_numpy()
, the timezone information is silently dropped.This has caused user confusion (see issue #45644).
This PR clarifies this behavior in the documentation and shows a minimal example. It also points users to
.to_pandas()
for preserving timezone-aware semantics.What changes are included in this PR?
docs/source/python/numpy.rst
under the "Arrow → NumPy" section..to_numpy()
returns a timezone-naivedatetime64
array..to_numpy()
vs.to_pandas()
.Are these changes tested?
Are there any user-facing changes?
.to_numpy()
limitations with timezone-aware Arrow timestamp arrays.This PR includes breaking changes to public APIs.
N/A — documentation only.
This PR contains a "Critical Fix".
N/A — documentation only.
to_numpy
#45644