You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "MarcoGorelli (via GitHub)" <gi...@apache.org> on 2023/06/15 07:39:38 UTC
[GitHub] [arrow] MarcoGorelli commented on issue #15047: [Python] Drop pytz for timezone support (default to use datetime.timezone / zoneinfo)
MarcoGorelli commented on issue #15047:
URL: https://github.com/apache/arrow/issues/15047#issuecomment-1592523553
Does it really fall back to pytz?
I don't have pytz installed:
```console
$ python -c 'import pytz'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pytz'
```
but trying to convert `2038-04-01 09:00` from 'America/Boise' to UTC, and I'm getting the same (wrong) result with pyarrow as I would with pandas:
```python
import pyarrow as pa
import pyarrow.compute as pc
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
string = '2038-04-01 03:00:00.000000'
dt = datetime.fromisoformat(string)
dt = dt.replace(tzinfo=ZoneInfo('America/Boise'))
tz = ZoneInfo('UTC')
converted_dt = dt.astimezone(tz)
print(converted_dt)
ts = pc.assume_timezone(pa.array([datetime(2038, 4, 1, 3)]), timezone='America/Boise')
print(ts)
```
This outputs
```python
2038-04-01 09:00:00+00:00
[
2038-04-01 10:00:00.000000
]
```
whereas I was expecting
```python
2038-04-01 09:00:00+00:00
[
2038-04-01 09:00:00.000000
]
```
Is there a way to "force" zoneinfo usage?
I think this is what's causing issues when converting polars to pandas: https://github.com/pola-rs/polars/issues/9315
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org