AlenkaF commented on issue #45644:
URL: https://github.com/apache/arrow/issues/45644#issuecomment-2693674211

   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
   
   ```python
   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]')
   ```
   ```python
   # 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
   # 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: 
https://github.com/apache/arrow/issues/41162.


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to