Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add whatsnew, more docs
  • Loading branch information
mroeschke committed Jan 24, 2024
commit a2adcf1ff3d54f9280669b97e3f5177277a22c44
36 changes: 34 additions & 2 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,44 @@ Optional libraries below the lowest tested version may still work, but are not c
+-----------------+---------------------+
| Package | New Minimum Version |
+=================+=====================+
| | |
| pytz | 2023.3 |
+-----------------+---------------------+

See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more.

.. _whatsnew_300.api_breaking.other:
.. _whatsnew_300.api_breaking.pytz:

``pytz`` now an optional dependency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

pandas now uses :py:mod:`zoneinfo` from the standard library as the default timezone implementation when passing a timezone
string to various methods. (:issue:`34916`)

*Old behavior:*

.. code-block:: ipython

In [1]: ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
In [2]: ts.tz
<DstTzInfo 'US/Pacific' LMT-1 day, 16:07:00 STD>

*New behavior:*

.. ipython:: python

ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
tz.tz


``pytz`` timezone objects are still supported when passed directly, but they will no longer be returned by default
from string inputs. Moreover, ``pytz`` is no longer a required dependency of pandas, but can be installed
with the pip extra ``pip install pandas[timezone]``.


Additionally, pandas no longer throws ``pytz`` exceptions for timezone operations leading to ambiguous or nonexistent
times. These operations will now yield :class:`errors.AmbiguousTimeError` and :class:`errors.NonexistentError`
and are accessible from :mod:`errors`.


Other API changes
^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 4 additions & 4 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ class NaTType(_NaT):

Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will be converted to.
None will remove timezone holding UTC time.

Expand Down Expand Up @@ -839,7 +839,7 @@ class NaTType(_NaT):
----------
ordinal : int
Date corresponding to a proleptic Gregorian ordinal.
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for the Timestamp.

Notes
Expand Down Expand Up @@ -1198,7 +1198,7 @@ timedelta}, default 'raise'

Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will be converted to.
None will remove timezone holding UTC time.

Expand Down Expand Up @@ -1245,7 +1245,7 @@ timedelta}, default 'raise'

Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, , dateutil.tz.tzfile or None
Time zone for time which Timestamp will be converted to.
None will remove timezone holding local time.

Expand Down
8 changes: 4 additions & 4 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ class Timestamp(_Timestamp):
hour, minute, second, microsecond : int, optional, default 0
tzinfo : datetime.tzinfo, optional, default None
nanosecond : int, optional, default 0
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will have.
unit : str
Unit used for conversion if ts_input is of type int or float. The
Expand Down Expand Up @@ -1343,7 +1343,7 @@ class Timestamp(_Timestamp):
----------
ordinal : int
Date corresponding to a proleptic Gregorian ordinal.
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for the Timestamp.

Notes
Expand Down Expand Up @@ -2223,7 +2223,7 @@ timedelta}, default 'raise'

Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will be converted to.
None will remove timezone holding local time.

Expand Down Expand Up @@ -2325,7 +2325,7 @@ default 'raise'

Parameters
----------
tz : str, pytz.timezone, dateutil.tz.tzfile or None
tz : str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time which Timestamp will be converted to.
None will remove timezone holding UTC time.

Expand Down