Skip to content

Commit cf094e6

Browse files
committed
GH-45644: [Doc][Python] Document timezone-aware NumPy object conversion
1 parent 7dcd9df commit cf094e6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

docs/source/python/numpy.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ If you need to preserve timezone information, there are two alternatives:
101101
1 2025-01-01 00:00:00+00:00
102102
dtype: datetime64[s, UTC]
103103
104+
To convert back to NumPy while preserving timezone information, use
105+
``timestamp_as_object=True`` to get an object array of Python ``datetime``
106+
objects:
107+
108+
.. code-block:: python
109+
110+
>>> arr.to_pandas(timestamp_as_object=True).to_numpy() # doctest: +ELLIPSIS
111+
array([datetime.datetime(2025, 1, 1, 0, 0, tzinfo=...),
112+
datetime.datetime(2025, 1, 1, 0, 0, tzinfo=...)],
113+
dtype=object)
114+
104115
.. note::
105116

106117
For nested types (e.g., list arrays containing timestamps),

0 commit comments

Comments
 (0)