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: Make pytz an optional dependency #57045

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a972881
Replace zoneinfo as default string inference, fix imports
mroeschke Jan 23, 2024
4b6ab5d
Adjust docs and tests
mroeschke Jan 24, 2024
b57f2ce
Make pytz optional, docs
mroeschke Jan 24, 2024
69ca55f
Bumpy pytz
mroeschke Jan 24, 2024
a2adcf1
Add whatsnew, more docs
mroeschke Jan 24, 2024
2cf6ecd
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 24, 2024
91c69ec
FIx test errors
mroeschke Jan 24, 2024
60c3f91
FIx some tests
mroeschke Jan 24, 2024
99ed33b
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 25, 2024
40900de
Fix more tests
mroeschke Jan 25, 2024
b8edf3d
A few more tests
mroeschke Jan 25, 2024
dd9b8fa
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 30, 2024
e45b390
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 31, 2024
c7b6a13
Fix doc and typing warnings
mroeschke Jan 31, 2024
d06fbb0
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 31, 2024
f144e00
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 31, 2024
a7a6395
Fix typing
mroeschke Jan 31, 2024
1e9f3e0
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jan 31, 2024
e5d6ec7
Remove ignores
mroeschke Feb 1, 2024
33f386a
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Feb 1, 2024
58b6271
Fix pylint, timezone test
mroeschke Feb 1, 2024
2a09819
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Feb 6, 2024
7958aa3
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Feb 12, 2024
0911f0a
Address pytz UTC usage
mroeschke Feb 12, 2024
6221c6e
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Feb 22, 2024
918c0c5
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Mar 14, 2024
3d43558
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Mar 19, 2024
8a75e61
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Apr 9, 2024
2ef88be
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Apr 15, 2024
fcf9ced
Fix typo
mroeschke Apr 15, 2024
235429f
Add see also
mroeschke Apr 15, 2024
79c03c8
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Apr 15, 2024
7f3bd1d
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Apr 24, 2024
5acac89
Merge remote-tracking branch 'upstream/main' into ref/tz/zoneinfo
mroeschke Jun 14, 2024
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
python -m pip list --no-cache-dir
export PANDAS_CI=1
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ jobs:
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.2.1 meson-python==0.13.1
python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true"
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
python -m pip list --no-cache-dir
export PANDAS_CI=1
Expand Down Expand Up @@ -266,7 +266,7 @@ jobs:
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
python -m pip list --no-cache-dir

Expand All @@ -287,7 +287,7 @@ jobs:
# In general, this will remain frozen(present, but not running) until:
# - The next unreleased Python version has released beta 1
# - This version should be available on GitHub Actions.
# - Our required build/runtime dependencies(numpy, pytz, Cython, python-dateutil)
# - Our required build/runtime dependencies(numpy, Cython, python-dateutil)
# support that unreleased Python version.
# To unfreeze, comment out the ``if: false`` condition, and make sure you update
# the name of the workflow and Python version in actions/setup-python ``python-version:``
Expand Down Expand Up @@ -340,7 +340,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.2.1 meson-python==0.13.1
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
python -m pip install versioneer[toml]
python -m pip install python-dateutil pytz tzdata cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov
python -m pip install python-dateutil tzdata cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov
python -m pip install -ve . --no-build-isolation --no-index --no-deps --config-settings=setup-args="--werror"
python -m pip list

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ details, see the commit logs at https://github.com/pandas-dev/pandas.
## Dependencies
- [NumPy - Adds support for large, multi-dimensional arrays, matrices and high-level mathematical functions to operate on these arrays](https://www.numpy.org)
- [python-dateutil - Provides powerful extensions to the standard datetime module](https://dateutil.readthedocs.io/en/stable/index.html)
- [pytz - Brings the Olson tz database into Python which allows accurate and cross platform timezone calculations](https://github.com/stub42/pytz)

See the [full installation instructions](https://pandas.pydata.org/pandas-docs/stable/install.html#dependencies) for minimum supported versions of required, recommended and optional dependencies.

Expand Down
15 changes: 9 additions & 6 deletions asv_bench/benchmarks/tslibs/timestamp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from datetime import datetime
from datetime import (
datetime,
timezone,
)
import zoneinfo

import numpy as np
import pytz

from pandas import Timestamp

Expand All @@ -12,7 +15,7 @@ class TimestampConstruction:
def setup(self):
self.npdatetime64 = np.datetime64("2020-01-01 00:00:00")
self.dttime_unaware = datetime(2020, 1, 1, 0, 0, 0)
self.dttime_aware = datetime(2020, 1, 1, 0, 0, 0, 0, pytz.UTC)
self.dttime_aware = datetime(2020, 1, 1, 0, 0, 0, 0, timezone.utc)
self.ts = Timestamp("2020-01-01 00:00:00")

def time_parse_iso8601_no_tz(self):
Expand Down Expand Up @@ -113,7 +116,7 @@ def setup(self, tz):
self.ts = Timestamp("2017-08-25 08:16:14", tz=tz)

def time_replace_tz(self, tz):
self.ts.replace(tzinfo=pytz.timezone("US/Eastern"))
self.ts.replace(tzinfo=zoneinfo.ZoneInfo("US/Eastern"))

def time_replace_None(self, tz):
self.ts.replace(tzinfo=None)
Expand Down Expand Up @@ -144,8 +147,8 @@ def time_ceil(self, tz):

class TimestampAcrossDst:
def setup(self):
dt = datetime(2016, 3, 27, 1)
self.tzinfo = pytz.timezone("CET").localize(dt, is_dst=False).tzinfo
dt = datetime(2016, 3, 27, 1, fold=0)
self.tzinfo = dt.astimezone(zoneinfo.ZoneInfo("Europe/Berlin")).tzinfo
self.ts2 = Timestamp(dt)

def time_replace_across_dst(self):
Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/tslibs/tslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
timedelta,
timezone,
)
import zoneinfo

from dateutil.tz import (
gettz,
tzlocal,
)
import numpy as np
import pytz

try:
from pandas._libs.tslibs import ints_to_pydatetime
Expand All @@ -38,7 +38,7 @@
None,
timezone.utc,
timezone(timedelta(minutes=60)),
pytz.timezone("US/Pacific"),
zoneinfo.ZoneInfo("US/Pacific"),
gettz("Asia/Tokyo"),
tzlocal_obj,
]
Expand Down
5 changes: 3 additions & 2 deletions asv_bench/benchmarks/tslibs/tz_convert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import timezone

import numpy as np
from pytz import UTC

from pandas._libs.tslibs.tzconversion import tz_localize_to_utc

Expand Down Expand Up @@ -41,7 +42,7 @@ def time_tz_convert_from_utc(self, size, tz):
# dti = DatetimeIndex(self.i8data, tz=tz)
# dti.tz_localize(None)
if old_sig:
tz_convert_from_utc(self.i8data, UTC, tz)
tz_convert_from_utc(self.i8data, timezone.utc, tz)
else:
tz_convert_from_utc(self.i8data, tz)

Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-310.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz

# optional dependencies
- beautifulsoup4>=4.11.2
Expand All @@ -46,6 +45,7 @@ dependencies:
- pyreadstat>=1.2.0
- pytables>=3.8.0
- python-calamine>=0.1.7
- pytz>=2023.3
- pyxlsb>=1.0.10
- s3fs>=2022.11.0
- scipy>=1.10.0
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-311-downstream_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz

# optional dependencies
- beautifulsoup4>=4.11.2
Expand All @@ -48,6 +47,7 @@ dependencies:
- pyreadstat>=1.2.0
- pytables>=3.8.0
- python-calamine>=0.1.7
- pytz>=2023.3
- pyxlsb>=1.0.10
- s3fs>=2022.11.0
- scipy>=1.10.0
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-311-numpydev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies:

# pandas dependencies
- python-dateutil
- pytz
- pip

- pip:
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-311-pyarrownightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz
- pip

- pip:
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-311.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz

# optional dependencies
- beautifulsoup4>=4.11.2
Expand All @@ -46,6 +45,7 @@ dependencies:
- pyreadstat>=1.2.0
- pytables>=3.8.0
- python-calamine>=0.1.7
- pytz>=2023.3
- pyxlsb>=1.0.10
- s3fs>=2022.11.0
- scipy>=1.10.0
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-312.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz

# optional dependencies
- beautifulsoup4>=4.11.2
Expand All @@ -46,6 +45,7 @@ dependencies:
- pyreadstat>=1.2.0
- pytables>=3.8.0
- python-calamine>=0.1.7
- pytz>=2023.3
- pyxlsb>=1.0.10
- s3fs>=2022.11.0
- scipy>=1.10.0
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-39-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dependencies:
# required dependencies
- python-dateutil=2.8.2
- numpy=1.23.5
- pytz=2020.1

# optional dependencies
- beautifulsoup4=4.11.2
Expand All @@ -49,6 +48,7 @@ dependencies:
- pyreadstat=1.2.0
- pytables=3.8.0
- python-calamine=0.1.7
- pytz=2023.3
- pyxlsb=1.0.10
- s3fs=2022.11.0
- scipy=1.10.0
Expand Down
2 changes: 1 addition & 1 deletion ci/deps/actions-39.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz

# optional dependencies
- beautifulsoup4>=4.11.2
Expand All @@ -46,6 +45,7 @@ dependencies:
- pyreadstat>=1.2.0
- pytables>=3.8.0
- python-calamine>=0.1.7
- pytz>=2023.3
- pyxlsb>=1.0.10
- s3fs>=2022.11.0
- scipy>=1.10.0
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-pypy-39.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ dependencies:
# required
- numpy
- python-dateutil
- pytz
- pip:
- tzdata>=2022.7
2 changes: 1 addition & 1 deletion ci/deps/circle-311-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies:
# required dependencies
- python-dateutil
- numpy
- pytz

# optional dependencies
- beautifulsoup4>=4.11.2
Expand All @@ -47,6 +46,7 @@ dependencies:
- pyreadstat>=1.2.0
- pytables>=3.8.0
- python-calamine>=0.1.7
- pytz>=2023.3
- pyxlsb>=1.0.10
- s3fs>=2022.11.0
- scipy>=1.10.0
Expand Down
1 change: 0 additions & 1 deletion ci/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ requirements:
- numpy >=1.21.6 # [py<311]
- numpy >=1.23.2 # [py>=311]
- python-dateutil >=2.8.2
- pytz >=2020.1
- python-tzdata >=2022.7

test:
Expand Down
13 changes: 12 additions & 1 deletion doc/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ Package Minimum support
================================================================ ==========================
`NumPy <https://numpy.org>`__ 1.23.5
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
`tzdata <https://pypi.org/project/tzdata/>`__ 2022.7
================================================================ ==========================

Expand Down Expand Up @@ -419,3 +418,15 @@ Dependency Minimum Version pip extra Notes
========================= ================== =============== =============================================================
Zstandard 0.19.0 compression Zstandard compression
========================= ================== =============== =============================================================


Timezone
^^^^^^^^

Installable with ``pip install "pandas[timezone]"``

========================= ================== =================== =============================================================
Dependency Minimum Version pip extra Notes
========================= ================== =================== =============================================================
pytz 2023.3 timezone Alternative timezone library to ``zoneinfo``.
========================= ================== =================== =============================================================
2 changes: 2 additions & 0 deletions doc/source/reference/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Exceptions and warnings
.. autosummary::
:toctree: api/

errors.AmbiguousTimeError
errors.AbstractMethodError
errors.AttributeConflictWarning
errors.CategoricalConversionWarning
Expand All @@ -45,6 +46,7 @@ Exceptions and warnings
errors.LossySetitemError
errors.MergeError
errors.NoBufferPresent
errors.NonExistentTimeError
errors.NullFrequencyError
errors.NumbaUtilError
errors.NumExprClobberingError
Expand Down
6 changes: 4 additions & 2 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4990,7 +4990,7 @@ Caveats
convenience you can use ``store.flush(fsync=True)`` to do this for you.
* Once a ``table`` is created columns (DataFrame)
are fixed; only exactly the same columns can be appended
* Be aware that timezones (e.g., ``pytz.timezone('US/Eastern')``)
* Be aware that timezones (e.g., ``zoneinfo.ZoneInfo('US/Eastern')``)
are not necessarily equal across timezone versions. So if data is
localized to a specific timezone in the HDFStore using one version
of a timezone library and that data is updated with another version, the data
Expand Down Expand Up @@ -5252,6 +5252,8 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an

.. ipython:: python

import pytz

df = pd.DataFrame(
{
"a": list("abc"),
Expand All @@ -5260,7 +5262,7 @@ See the documentation for `pyarrow <https://arrow.apache.org/docs/python/>`__ an
"d": np.arange(4.0, 7.0, dtype="float64"),
"e": [True, False, True],
"f": pd.date_range("20130101", periods=3),
"g": pd.date_range("20130101", periods=3, tz="US/Eastern"),
"g": pd.date_range("20130101", periods=3, tz=pytz.timezone("US/Eastern")),
"h": pd.Categorical(list("abc")),
"i": pd.Categorical(list("abc"), ordered=True),
}
Expand Down
Loading
Loading