Skip to content

[Doc][Python] Timestamp with tz loses its time zone after to_numpy #45644

Description

@sharkdtu

Describe the bug, including details regarding any error messages, version, and platform.

Timestamptz type loses its time zone after to_numpy.

Versions / Dependencies

In [44]: pa.__version__
Out[44]: '19.0.1'

Reproduction script

In [39]: import pyarrow as pa

In [40]: x = pa.array([1735689600, 1735689600, 1735689600], type=pa.timestamp("s", tz='UTC'))

In [41]: print(x.type)
timestamp[s, tz=UTC]

In [42]: y = x.to_numpy()

In [43]: print(y.dtype)
datetime64[s]

Component(s)

Python

Activity

  1. changed the title [-][Python] Timestamptz type loses its time zone after map transforming.[/-] [+][Python] Timestamp with tz loses its time zone after `to_numpy`[/+] on Feb 28, 2025
  2. AlenkaF commented on Mar 3, 2025

    @AlenkaF
    Member

    This behaviour is expected as NumPy datetimes are not timezone aware, see https://numpy.org/devdocs/reference/arrays.datetime.html#datetimes-and-timedeltas.

    You can convert pyarrow tz-aware timestamp array to

    • numpy datetime64 with loss of tz information,
    • pandas tz-aware datetime64 dtype
    • a Pyhon object
    arr_tz = pa.array([1735689600, 1735689600, 1735689600], type=pa.timestamp("s", tz='UTC'))
    
    # numpy datetime64 dtype (losing tz information)
    >>> arr_tz.to_numpy()
    array(['2025-01-01T00:00:00', '2025-01-01T00:00:00',
           '2025-01-01T00:00:00'], dtype='datetime64[s]')
    # pandas tz-aware datetime64 dtype
    >>> arr_tz.to_pandas().array
    0   2025-01-01 00:00:00+00:00
    1   2025-01-01 00:00:00+00:00
    2   2025-01-01 00:00:00+00:00
    dtype: datetime64[s, UTC]
    # python object
    >>> arr_tz.to_pandas(timestamp_as_object=True).to_numpy()
    array([datetime.datetime(2025, 1, 1, 0, 0, tzinfo=<UTC>),
           datetime.datetime(2025, 1, 1, 0, 0, tzinfo=<UTC>),
           datetime.datetime(2025, 1, 1, 0, 0, tzinfo=<UTC>)], dtype=object)

    I will keep this issue open as this needs to be documented in https://arrow.apache.org/docs/python/numpy.html.
    Also connected and need to go into the docs: #41162.

  3. added
    Type: usageIssue is a user question
    and removed on Mar 3, 2025
  4. changed the title [-][Python] Timestamp with tz loses its time zone after `to_numpy`[/-] [+][Doc][Python] Timestamp with tz loses its time zone after `to_numpy`[/+] on Mar 10, 2025
  5. added a commit that references this issue on Oct 2, 2025
    287b626
  6. Bhupendra-glitch commented on Jan 1, 2026

    @Bhupendra-glitch

    Hello @AlenkaF
    I’d like to work on documenting the timezone behavior when converting PyArrow timestamp arrays to NumPy.
    I plan to add a section to the Python NumPy documentation explaining the loss of timezone info and the recommended alternatives.

  7. alex-anast commented on Apr 22, 2026

    @alex-anast
    Contributor

    Hi @AlenkaF I've opened up a PR for this. Could you please take a look? 🙏

  8. added 4 commits that reference this issue on Apr 23, 2026
  9. added a commit that references this issue on May 5, 2026
  10. added a commit that references this issue on May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions