Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPS/TST: tzdata is optional, not required #47467

Merged
merged 17 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/deps/actions-310.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
- scipy
- sqlalchemy
- tabulate
- tzdata>=2022.1
- xarray
- xlrd
- xlsxwriter
Expand Down
1 change: 1 addition & 0 deletions ci/deps/actions-38-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies:
- scipy=1.7.1
- sqlalchemy=1.4.16
- tabulate=0.8.9
- tzdata=2022.1
- xarray=0.19.0
- xlrd=2.0.1
- xlsxwriter=1.4.3
Expand Down
1 change: 1 addition & 0 deletions ci/deps/actions-39.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
- scipy
- sqlalchemy
- tabulate
- tzdata>=2022.1
- xarray
- xlrd
- xlsxwriter
Expand Down
9 changes: 9 additions & 0 deletions doc/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ For example, :func:`pandas.read_hdf` requires the ``pytables`` package, while
optional dependency is not installed, pandas will raise an ``ImportError`` when
the method requiring that dependency is called.

Timezones
^^^^^^^^^

========================= ================== =============================================================
Dependency Minimum Version Notes
========================= ================== =============================================================
tzdata 2022.1 Allows the use of ``zoneinfo`` timezones with pandas
lithomas1 marked this conversation as resolved.
Show resolved Hide resolved
========================= ================== =============================================================

Visualization
^^^^^^^^^^^^^

Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies:
- scipy
- sqlalchemy
- tabulate
- tzdata>=2022.1
- xarray
- xlrd
- xlsxwriter
Expand Down
3 changes: 3 additions & 0 deletions pandas/_libs/tslibs/timezones.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ from datetime import (
timezone,
)

from pandas.compat._optional import import_optional_dependency

try:
# py39+
import zoneinfo
from zoneinfo import ZoneInfo
import_optional_dependency("tzdata", errors="raise", min_version="2022.1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we should only check tzdata if the user doesn't have an OS that already has system timezones that are available.

import zoneinfo
from zoneinfo import ZoneInfo
try:
    ZoneInfo("UTC")
except zoneinfo.ZoneInfoNotFoundError:
    import_optional_dependency("tzdata", errors="warn", min_version="2022.1")

Also I think errors="warn" since tzdata is still optional, and the user may not necessarily use ZoneInfo objects when using pandas (since it's not the default yet)

except ImportError:
zoneinfo = None
ZoneInfo = None
Expand Down
1 change: 1 addition & 0 deletions pandas/compat/_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"xlwt": "1.3.0",
"xlsxwriter": "1.4.3",
"zstandard": "0.15.2",
"tzdata": "2022.1",
}

# A mapping from import name to package name (on PyPI) for packages where
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ s3fs
scipy
sqlalchemy
tabulate
tzdata>=2022.1
xarray
xlrd
xlsxwriter
Expand Down