AlenkaF commented on code in PR #49843:
URL: https://github.com/apache/arrow/pull/49843#discussion_r3181661058
##########
docs/source/python/numpy.rst:
##########
@@ -73,3 +73,56 @@ representation as Arrow, and assuming the Arrow data has no
nulls.
For more complex data types, you have to use the
:meth:`~pyarrow.Array.to_pandas`
method (which will construct a Numpy array with Pandas semantics for, e.g.,
representation of null values).
+
+Timezone-aware Timestamps
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+NumPy's ``datetime64`` type does not support timezones. When converting a
+timezone-aware Arrow timestamp array to NumPy via
:meth:`~pyarrow.Array.to_numpy`,
+the timezone information is silently dropped:
+
+.. code-block:: python
+
+ >>> arr = pa.array([1735689600, 1735689600], type=pa.timestamp("s",
tz="UTC"))
+ >>> arr.type
+ TimestampType(timestamp[s, tz=UTC])
+ >>> arr.to_numpy()
+ array(['2025-01-01T00:00:00', '2025-01-01T00:00:00'],
+ dtype='datetime64[s]')
+
+If you need to preserve timezone information, there are two alternatives:
+
+* Convert to a Pandas Series, which supports timezone-aware ``datetime64``
dtypes:
+
+ .. code-block:: python
+
+ >>> arr.to_pandas()
+ 0 2025-01-01 00:00:00+00:00
+ 1 2025-01-01 00:00:00+00:00
+ dtype: datetime64[s, UTC]
+
+ To convert back to NumPy while preserving timezone information, use
+ ``timestamp_as_object=True`` to get an object array of Python ``datetime``
+ objects:
Review Comment:
```suggestion
To get a NumPy array while preserving timezone information, use
``timestamp_as_object=True``:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]