nph opened a new issue, #38629:
URL: https://github.com/apache/arrow/issues/38629
### Describe the bug, including details regarding any error messages,
version, and platform.
Printing a `Table` or a `RecordBatch` containing timezone-aware timestamps
displays the time values in UTC but shows the original (possibly non-UTC)
timezone in the schema header.
```
import datetime as dt
import pyarrow as pa
from pytz import timezone
# Create a table from a non-UTC timestamp
pacific_tz = timezone('US/Pacific')
mapping = [{'datetime': pacific_tz.localize(dt.datetime(2023, 11, 7, 22, 0,
0))}]
print(mapping)
# [{'datetime': datetime.datetime(2023, 11, 7, 22, 0, tzinfo=<DstTzInfo
'US/Pacific' PST-1 day, 16:00:00 STD>)}]
table = pa.Table.from_pylist(mapping)
# Table repr displays the timestamp values as UTC but shows the original
timezone in the schema header
print(table)
# pyarrow.Table
# datetime: timestamp[us, tz=US/Pacific] <-- incorrect timezone
# ----
# datetime: [[2023-11-08 06:00:00.000000]] <-- timestamps in UTC
# Confirm the underlying table data is correct
print(table.to_pylist())
# [{'datetime': datetime.datetime(2023, 11, 7, 22, 0, tzinfo=<DstTzInfo
'US/Pacific' PST-1 day, 16:00:00 STD>)}]
# Create a table from a UTC timestamp
mapping = [{'datetime': dt.datetime(2023, 11, 7, 22, 0, 0,
tzinfo=dt.timezone.utc)}]
table = pa.Table.from_pylist(mapping)
# Printing the table shows the correct timezone in the schema header
print(table)
# pyarrow.Table
# datetime: timestamp[us, tz=UTC]
# ----
# datetime: [[2023-11-07 22:00:00.000000]]
```
See also this related DuckDB
[issue](https://github.com/duckdb/duckdb/issues/9381)
**Pyarrow Version:**
13.0.0
**Platform:**
macOS 12.7
### Component(s)
Python
--
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]