apache / apache/arrow

[Python] Drop pytz for timezone support (default to use datetime.timezone / zoneinfo)

Open
#15,047 9 comments 0 reactions 1 assignee Claimed by @jorisvandenbossche View on GitHub
Component: Python
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 18h
Merged PRs (30d)
91

Description

We already made pytz an optional dependency a while ago (ARROW-15580, https://github.com/apache/arrow/pull/12522), so you can now convert arrow timestamp with tz to python without having pytz. In the case pytz is not installed, we "fall back" to `datetime.timezone(datetime.timedelta(..))` for fixed offsets and `zoneinfo.ZoneInfo(..)` for known time zones.

However, we should make this fall back the default at some point (and potentially dropping the option to convert to pytz automatically altogether).
Pandas starts to do this in pandas 2.0 for fixed offsets (https://pandas.pydata.org/docs/dev/whatsnew/v2.0.0.html#utc-and-fixed-offset-timezones-default-to-standard-library-tzinfo-objects)

One complication for this is that the `zoneinfo` module is only available in the standard library starting with Python 3.9, while we still support older versions (which would require https://pypi.org/project/backports.zoneinfo/ if we want consistent behaviour across all python versions)

### 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.