Skip to content

Conversation

Kripa21
Copy link

@Kripa21 Kripa21 commented Oct 2, 2025

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?

  • Added a note in docs/source/python/numpy.rst under the "Arrow → NumPy" section.
  • The note explicitly states that .to_numpy() returns a timezone-naive datetime64 array.
  • Added a minimal code example comparing .to_numpy() vs .to_pandas().

Are these changes tested?

  • Not applicable: this is a documentation-only change.
  • The included code snippet was run locally to confirm correctness.

Are there any user-facing changes?

  • Yes: clearer documentation of .to_numpy() limitations with timezone-aware Arrow timestamp arrays.
  • No API or functional changes.

This PR includes breaking changes to public APIs.
N/A — documentation only.

This PR contains a "Critical Fix".
N/A — documentation only.

Copy link

github-actions bot commented Oct 2, 2025

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

@Kripa21 Kripa21 changed the title DOC: clarify that Array.to_numpy() drops timezone for timestamp array… GH-45644: Documentation Timestamp with tz loses its time zone after to_numpy Oct 2, 2025
Copy link

github-actions bot commented Oct 2, 2025

⚠️ GitHub issue #45644 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc][Python] Timestamp with tz loses its time zone after to_numpy
1 participant