Skip to content

Commit edb3670

Browse files
committed
Resolve merge conflict by incorporating both suggestions
2 parents 5633f8d + fb6842d commit edb3670

File tree

85 files changed

+695
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+695
-414
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
5757
. ~/virtualenvs/pandas-dev/bin/activate
5858
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
59-
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
59+
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
6060
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
6161
python -m pip list --no-cache-dir
6262
export PANDAS_CI=1

.github/workflows/unit-tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ jobs:
236236
. ~/virtualenvs/pandas-dev/bin/activate
237237
python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.2.1 meson-python==0.13.1
238238
python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true"
239-
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytz pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
239+
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
240240
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
241241
python -m pip list --no-cache-dir
242242
export PANDAS_CI=1
@@ -274,7 +274,7 @@ jobs:
274274
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
275275
. ~/virtualenvs/pandas-dev/bin/activate
276276
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
277-
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
277+
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
278278
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
279279
python -m pip list --no-cache-dir
280280
@@ -295,7 +295,7 @@ jobs:
295295
# In general, this will remain frozen(present, but not running) until:
296296
# - The next unreleased Python version has released beta 1
297297
# - This version should be available on GitHub Actions.
298-
# - Our required build/runtime dependencies(numpy, pytz, Cython, python-dateutil)
298+
# - Our required build/runtime dependencies(numpy, Cython, python-dateutil)
299299
# support that unreleased Python version.
300300
# To unfreeze, comment out the ``if: false`` condition, and make sure you update
301301
# the name of the workflow and Python version in actions/setup-python ``python-version:``
@@ -348,7 +348,7 @@ jobs:
348348
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.2.1 meson-python==0.13.1
349349
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
350350
python -m pip install versioneer[toml]
351-
python -m pip install python-dateutil pytz tzdata cython hypothesis>=6.84.0 pytest>=7.3.2 pytest-xdist>=3.4.0 pytest-cov
351+
python -m pip install python-dateutil tzdata cython hypothesis>=6.84.0 pytest>=7.3.2 pytest-xdist>=3.4.0 pytest-cov
352352
python -m pip install -ve . --no-build-isolation --no-index --no-deps --config-settings=setup-args="--werror"
353353
python -m pip list
354354

ci/code_checks.sh

+14-18
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,15 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
158158
-i "pandas.Series.sparse.sp_values SA01" \
159159
-i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \
160160
-i "pandas.Series.std PR01,RT03,SA01" \
161-
-i "pandas.Series.str.capitalize RT03" \
162-
-i "pandas.Series.str.casefold RT03" \
163-
-i "pandas.Series.str.center RT03,SA01" \
164-
-i "pandas.Series.str.decode PR07,RT03,SA01" \
165-
-i "pandas.Series.str.encode PR07,RT03,SA01" \
166-
-i "pandas.Series.str.ljust RT03,SA01" \
167-
-i "pandas.Series.str.lower RT03" \
168161
-i "pandas.Series.str.lstrip RT03" \
169162
-i "pandas.Series.str.match RT03" \
170163
-i "pandas.Series.str.normalize RT03,SA01" \
171164
-i "pandas.Series.str.partition RT03" \
172165
-i "pandas.Series.str.repeat SA01" \
173166
-i "pandas.Series.str.replace SA01" \
174-
-i "pandas.Series.str.rjust RT03,SA01" \
175167
-i "pandas.Series.str.rpartition RT03" \
176168
-i "pandas.Series.str.rstrip RT03" \
177169
-i "pandas.Series.str.strip RT03" \
178-
-i "pandas.Series.str.swapcase RT03" \
179-
-i "pandas.Series.str.title RT03" \
180-
-i "pandas.Series.str.upper RT03" \
181170
-i "pandas.Series.str.wrap RT03,SA01" \
182171
-i "pandas.Series.str.zfill RT03" \
183172
-i "pandas.Series.struct.dtypes SA01" \
@@ -231,13 +220,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
231220
-i "pandas.Timestamp.to_period PR01,SA01" \
232221
-i "pandas.Timestamp.today SA01" \
233222
-i "pandas.Timestamp.toordinal SA01" \
234-
-i "pandas.Timestamp.tz_localize SA01" \
235223
-i "pandas.Timestamp.tzinfo GL08" \
236-
-i "pandas.Timestamp.tzname SA01" \
237-
-i "pandas.Timestamp.unit SA01" \
238-
-i "pandas.Timestamp.utcfromtimestamp PR01,SA01" \
239-
-i "pandas.Timestamp.utcoffset SA01" \
240-
-i "pandas.Timestamp.utctimetuple SA01" \
241224
-i "pandas.Timestamp.value GL08" \
242225
-i "pandas.Timestamp.year GL08" \
243226
-i "pandas.api.extensions.ExtensionArray._pad_or_backfill PR01,RT03,SA01" \
@@ -508,10 +491,14 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
508491
-i "pandas.tseries.offsets.Day.n GL08" \
509492
-i "pandas.tseries.offsets.Day.normalize GL08" \
510493
-i "pandas.tseries.offsets.Easter PR02" \
494+
-i "pandas.tseries.offsets.Day.rule_code GL08" \
495+
-i "pandas.tseries.offsets.Easter.freqstr SA01" \
511496
-i "pandas.tseries.offsets.Easter.is_on_offset GL08" \
512497
-i "pandas.tseries.offsets.Easter.n GL08" \
513498
-i "pandas.tseries.offsets.Easter.normalize GL08" \
514499
-i "pandas.tseries.offsets.FY5253 PR02" \
500+
-i "pandas.tseries.offsets.Easter.rule_code GL08" \
501+
-i "pandas.tseries.offsets.FY5253.freqstr SA01" \
515502
-i "pandas.tseries.offsets.FY5253.get_rule_code_suffix GL08" \
516503
-i "pandas.tseries.offsets.FY5253.get_year_end GL08" \
517504
-i "pandas.tseries.offsets.FY5253.is_on_offset GL08" \
@@ -522,6 +509,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
522509
-i "pandas.tseries.offsets.FY5253.variation GL08" \
523510
-i "pandas.tseries.offsets.FY5253.weekday GL08" \
524511
-i "pandas.tseries.offsets.FY5253Quarter PR02" \
512+
-i "pandas.tseries.offsets.FY5253Quarter.freqstr SA01" \
525513
-i "pandas.tseries.offsets.FY5253Quarter.get_rule_code_suffix GL08" \
526514
-i "pandas.tseries.offsets.FY5253Quarter.get_weeks GL08" \
527515
-i "pandas.tseries.offsets.FY5253Quarter.is_on_offset GL08" \
@@ -534,24 +522,32 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
534522
-i "pandas.tseries.offsets.FY5253Quarter.weekday GL08" \
535523
-i "pandas.tseries.offsets.FY5253Quarter.year_has_extra_week GL08" \
536524
-i "pandas.tseries.offsets.Hour PR02" \
525+
-i "pandas.tseries.offsets.Hour.freqstr SA01" \
537526
-i "pandas.tseries.offsets.Hour.is_on_offset GL08" \
538527
-i "pandas.tseries.offsets.Hour.n GL08" \
539528
-i "pandas.tseries.offsets.Hour.normalize GL08" \
540529
-i "pandas.tseries.offsets.LastWeekOfMonth PR02,SA01" \
530+
-i "pandas.tseries.offsets.Hour.rule_code GL08" \
531+
-i "pandas.tseries.offsets.LastWeekOfMonth SA01" \
532+
-i "pandas.tseries.offsets.LastWeekOfMonth.freqstr SA01" \
541533
-i "pandas.tseries.offsets.LastWeekOfMonth.is_on_offset GL08" \
542534
-i "pandas.tseries.offsets.LastWeekOfMonth.n GL08" \
543535
-i "pandas.tseries.offsets.LastWeekOfMonth.normalize GL08" \
544536
-i "pandas.tseries.offsets.LastWeekOfMonth.week GL08" \
545537
-i "pandas.tseries.offsets.LastWeekOfMonth.weekday GL08" \
546538
-i "pandas.tseries.offsets.Micro PR02" \
539+
-i "pandas.tseries.offsets.Micro.freqstr SA01" \
547540
-i "pandas.tseries.offsets.Micro.is_on_offset GL08" \
548541
-i "pandas.tseries.offsets.Micro.n GL08" \
549542
-i "pandas.tseries.offsets.Micro.normalize GL08" \
550543
-i "pandas.tseries.offsets.Milli PR02" \
544+
-i "pandas.tseries.offsets.Micro.rule_code GL08" \
545+
-i "pandas.tseries.offsets.Milli.freqstr SA01" \
551546
-i "pandas.tseries.offsets.Milli.is_on_offset GL08" \
552547
-i "pandas.tseries.offsets.Milli.n GL08" \
553548
-i "pandas.tseries.offsets.Milli.normalize GL08" \
554-
-i "pandas.tseries.offsets.Minute PR02" \
549+
-i "pandas.tseries.offsets.Milli.rule_code GL08" \
550+
-i "pandas.tseries.offsets.Minute.freqstr SA01" \
555551
-i "pandas.tseries.offsets.Minute.is_on_offset GL08" \
556552
-i "pandas.tseries.offsets.Minute.n GL08" \
557553
-i "pandas.tseries.offsets.Minute.normalize GL08" \

ci/deps/actions-310-minimum_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies:
2323
# required dependencies
2424
- python-dateutil=2.8.2
2525
- numpy=1.23.5
26-
- pytz=2020.1
2726

2827
# optional dependencies
2928
- beautifulsoup4=4.11.2
@@ -49,6 +48,7 @@ dependencies:
4948
- pyreadstat=1.2.0
5049
- pytables=3.8.0
5150
- python-calamine=0.1.7
51+
- pytz=2023.4
5252
- pyxlsb=1.0.10
5353
- s3fs=2022.11.0
5454
- scipy=1.10.0

ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies:
2121
# required dependencies
2222
- python-dateutil
2323
- numpy
24-
- pytz
2524

2625
# optional dependencies
2726
- beautifulsoup4>=4.11.2
@@ -47,6 +46,7 @@ dependencies:
4746
- pyreadstat>=1.2.0
4847
- pytables>=3.8.0
4948
- python-calamine>=0.1.7
49+
- pytz>=2023.4
5050
- pyxlsb>=1.0.10
5151
- s3fs>=2022.11.0
5252
- scipy>=1.10.0

ci/deps/actions-311-downstream_compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ dependencies:
2222
# required dependencies
2323
- python-dateutil
2424
- numpy
25-
- pytz
2625

2726
# optional dependencies
2827
- beautifulsoup4>=4.11.2
@@ -48,6 +47,7 @@ dependencies:
4847
- pyreadstat>=1.2.0
4948
- pytables>=3.8.0
5049
- python-calamine>=0.1.7
50+
- pytz>=2023.4
5151
- pyxlsb>=1.0.10
5252
- s3fs>=2022.11.0
5353
- scipy>=1.10.0

ci/deps/actions-311-numpydev.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ dependencies:
1818

1919
# pandas dependencies
2020
- python-dateutil
21-
- pytz
2221
- pip
2322

2423
- pip:

ci/deps/actions-311-pyarrownightly.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ dependencies:
1919
# required dependencies
2020
- python-dateutil
2121
- numpy<2
22-
- pytz
2322
- pip
2423

2524
- pip:

ci/deps/actions-311.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies:
2121
# required dependencies
2222
- python-dateutil
2323
- numpy
24-
- pytz
2524

2625
# optional dependencies
2726
- beautifulsoup4>=4.11.2
@@ -47,6 +46,7 @@ dependencies:
4746
- pyreadstat>=1.2.0
4847
- pytables>=3.8.0
4948
- python-calamine>=0.1.7
49+
- pytz>=2023.4
5050
- pyxlsb>=1.0.10
5151
- s3fs>=2022.11.0
5252
- scipy>=1.10.0

ci/deps/actions-312.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies:
2121
# required dependencies
2222
- python-dateutil
2323
- numpy
24-
- pytz
2524

2625
# optional dependencies
2726
- beautifulsoup4>=4.11.2
@@ -47,6 +46,7 @@ dependencies:
4746
- pyreadstat>=1.2.0
4847
- pytables>=3.8.0
4948
- python-calamine>=0.1.7
49+
- pytz>=2023.4
5050
- pyxlsb>=1.0.10
5151
- s3fs>=2022.11.0
5252
- scipy>=1.10.0

ci/deps/actions-pypy-39.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ dependencies:
2222
# required
2323
- numpy
2424
- python-dateutil
25-
- pytz
2625
- pip:
2726
- tzdata>=2022.7

ci/deps/circle-311-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ dependencies:
2121
# required dependencies
2222
- python-dateutil
2323
- numpy
24-
- pytz
2524

2625
# optional dependencies
2726
- beautifulsoup4>=4.11.2
@@ -47,6 +46,7 @@ dependencies:
4746
- pyreadstat>=1.2.0
4847
- pytables>=3.8.0
4948
- python-calamine>=0.1.7
49+
- pytz>=2023.4
5050
- pyxlsb>=1.0.10
5151
- s3fs>=2022.11.0
5252
- scipy>=1.10.0

ci/meta.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ requirements:
3737
- numpy >=1.21.6 # [py<311]
3838
- numpy >=1.23.2 # [py>=311]
3939
- python-dateutil >=2.8.2
40-
- pytz >=2020.1
4140
- python-tzdata >=2022.7
4241

4342
test:

doc/source/development/contributing_docstring.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ backticks. The following are considered inline code:
142142
143143
With several mistakes in the docstring.
144144
145-
It has a blank like after the signature ``def func():``.
145+
It has a blank line after the signature ``def func():``.
146146
147147
The text 'Some function' should go in the line after the
148148
opening quotes of the docstring, not in the same line.

doc/source/getting_started/install.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ Package Minimum support
205205
================================================================ ==========================
206206
`NumPy <https://numpy.org>`__ 1.23.5
207207
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
208-
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
209208
`tzdata <https://pypi.org/project/tzdata/>`__ 2022.7
210209
================================================================ ==========================
211210

@@ -419,3 +418,14 @@ Dependency Minimum Version pip extra Notes
419418
========================= ================== =============== =============================================================
420419
Zstandard 0.19.0 compression Zstandard compression
421420
========================= ================== =============== =============================================================
421+
422+
Timezone
423+
^^^^^^^^
424+
425+
Installable with ``pip install "pandas[timezone]"``
426+
427+
========================= ================== =================== =============================================================
428+
Dependency Minimum Version pip extra Notes
429+
========================= ================== =================== =============================================================
430+
pytz 2023.4 timezone Alternative timezone library to ``zoneinfo``.
431+
========================= ================== =================== =============================================================

doc/source/user_guide/timeseries.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ Ambiguous times when localizing
25692569
because daylight savings time (DST) in a local time zone causes some times to occur
25702570
twice within one day ("clocks fall back"). The following options are available:
25712571

2572-
* ``'raise'``: Raises a ``pytz.AmbiguousTimeError`` (the default behavior)
2572+
* ``'raise'``: Raises a ``ValueError`` (the default behavior)
25732573
* ``'infer'``: Attempt to determine the correct offset base on the monotonicity of the timestamps
25742574
* ``'NaT'``: Replaces ambiguous times with ``NaT``
25752575
* ``bool``: ``True`` represents a DST time, ``False`` represents non-DST time. An array-like of ``bool`` values is supported for a sequence of times.
@@ -2604,7 +2604,7 @@ A DST transition may also shift the local time ahead by 1 hour creating nonexist
26042604
local times ("clocks spring forward"). The behavior of localizing a timeseries with nonexistent times
26052605
can be controlled by the ``nonexistent`` argument. The following options are available:
26062606

2607-
* ``'raise'``: Raises a ``pytz.NonExistentTimeError`` (the default behavior)
2607+
* ``'raise'``: Raises a ``ValueError`` (the default behavior)
26082608
* ``'NaT'``: Replaces nonexistent times with ``NaT``
26092609
* ``'shift_forward'``: Shifts nonexistent times forward to the closest real time
26102610
* ``'shift_backward'``: Shifts nonexistent times backward to the closest real time

doc/source/whatsnew/v3.0.0.rst

+35
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Optional libraries below the lowest tested version may still work, but are not c
221221
+------------------------+---------------------+
222222
| Package | New Minimum Version |
223223
+========================+=====================+
224+
| pytz | 2023.4 |
225+
+------------------------+---------------------+
224226
| fastparquet | 2023.10.0 |
225227
+------------------------+---------------------+
226228
| adbc-driver-postgresql | 0.10.0 |
@@ -230,6 +232,37 @@ Optional libraries below the lowest tested version may still work, but are not c
230232

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

235+
.. _whatsnew_300.api_breaking.pytz:
236+
237+
``pytz`` now an optional dependency
238+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
239+
240+
pandas now uses :py:mod:`zoneinfo` from the standard library as the default timezone implementation when passing a timezone
241+
string to various methods. (:issue:`34916`)
242+
243+
*Old behavior:*
244+
245+
.. code-block:: ipython
246+
247+
In [1]: ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
248+
In [2]: ts.tz
249+
<DstTzInfo 'US/Pacific' LMT-1 day, 16:07:00 STD>
250+
251+
*New behavior:*
252+
253+
.. ipython:: python
254+
255+
ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
256+
ts.tz
257+
258+
``pytz`` timezone objects are still supported when passed directly, but they will no longer be returned by default
259+
from string inputs. Moreover, ``pytz`` is no longer a required dependency of pandas, but can be installed
260+
with the pip extra ``pip install pandas[timezone]``.
261+
262+
263+
Additionally, pandas no longer throws ``pytz`` exceptions for timezone operations leading to ambiguous or nonexistent
264+
times. These cases will now raise a ``ValueError``.
265+
233266
.. _whatsnew_300.api_breaking.other:
234267

235268
Other API changes
@@ -621,6 +654,7 @@ Reshaping
621654
^^^^^^^^^
622655
- Bug in :func:`qcut` where values at the quantile boundaries could be incorrectly assigned (:issue:`59355`)
623656
- Bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
657+
- Bug in :meth:`DataFrame.merge` where merging on a column containing only ``NaN`` values resulted in an out-of-bounds array access (:issue:`59421`)
624658
- Bug in :meth:`DataFrame.unstack` producing incorrect results when ``sort=False`` (:issue:`54987`, :issue:`55516`)
625659
- Bug in :meth:`DataFrame.unstack` producing incorrect results when manipulating empty :class:`DataFrame` with an :class:`ExtentionDtype` (:issue:`59123`)
626660

@@ -633,6 +667,7 @@ ExtensionArray
633667
^^^^^^^^^^^^^^
634668
- Bug in :meth:`.arrays.ArrowExtensionArray.__setitem__` which caused wrong behavior when using an integer array with repeated values as a key (:issue:`58530`)
635669
- Bug in :meth:`api.types.is_datetime64_any_dtype` where a custom :class:`ExtensionDtype` would return ``False`` for array-likes (:issue:`57055`)
670+
- Bug in comparison between object with :class:`ArrowDtype` and incompatible-dtyped (e.g. string vs bool) incorrectly raising instead of returning all-``False`` (for ``==``) or all-``True`` (for ``!=``) (:issue:`59505`)
636671
- Bug in various :class:`DataFrame` reductions for pyarrow temporal dtypes returning incorrect dtype when result was null (:issue:`59234`)
637672

638673
Styler

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ dependencies:
2424
# required dependencies
2525
- python-dateutil
2626
- numpy<2
27-
- pytz
2827

2928
# optional dependencies
3029
- beautifulsoup4>=4.11.2
@@ -50,6 +49,7 @@ dependencies:
5049
- pyreadstat>=1.2.0
5150
- pytables>=3.8.0
5251
- python-calamine>=0.1.7
52+
- pytz>=2023.4
5353
- pyxlsb>=1.0.10
5454
- s3fs>=2022.11.0
5555
- scipy>=1.10.0

0 commit comments

Comments
 (0)