apache / apache/arrow

[Python] array constructor ignore time zone in `type`

Open
#37,342 1 comment 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

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

```python
In [16]: pa.array([datetime(2020, 1, 1, tzinfo=timezone(timedelta(hours=-8)))], type=pa.timestamp('us', 'US/Pacific'))
Out[16]:

[
2020-01-01 08:00:00.000000
]

In [17]: pa.array([datetime(2020, 1, 1, tzinfo=timezone(timedelta(hours=-8)))], type=pa.timestamp('us', 'UTC'))
Out[17]:

[
2020-01-01 08:00:00.000000
]

In [18]: pa.array([datetime(2020, 1, 1)], type=pa.timestamp('us', 'US/Pacific'))
Out[18]:

[
2020-01-01 00:00:00.000000
]
```

Note how the result doesn't depend on the time zone I put in the `type` argument

Is this intentional? I'm not saying it's a bug or that it needs to change, it just came up in Polars: https://github.com/pola-rs/polars/issues/10662 - I just want to make sure that if there is any change, then we all go towards the same direction

versions:
- python: 3.10.6
- pyarrow: 13.0.0

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.