Skip to content

Commit 2e283a7

Browse files
committed
Merge branch 'main' into 50040-add-math-mode-formatter-escape=latex-part2
2 parents c20e795 + f08871d commit 2e283a7

Some content is hidden

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

46 files changed

+551
-564
lines changed

.github/actions/build_pandas/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ runs:
1616
python -m pip install -e . --no-build-isolation --no-use-pep517 --no-index
1717
shell: bash -el {0}
1818
env:
19-
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
20-
N_JOBS: ${{ runner.os == 'macOS' && 3 || 2 }}
19+
# Cannot use parallel compilation on Windows, see https://github.com/pandas-dev/pandas/issues/30873
20+
# GH 47305: Parallel build causes flaky ImportError: /home/runner/work/pandas/pandas/pandas/_libs/tslibs/timestamps.cpython-38-x86_64-linux-gnu.so: undefined symbol: pandas_datetime_to_datetimestruct
21+
N_JOBS: 1
22+
#N_JOBS: ${{ runner.os == 'Windows' && 1 || 2 }}

.github/actions/setup-conda/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ runs:
3030
environment-name: ${{ inputs.environment-name }}
3131
extra-specs: ${{ inputs.extra-specs }}
3232
channels: conda-forge
33-
channel-priority: 'strict'
33+
channel-priority: ${{ runner.os == 'macOS' && 'flexible' || 'strict' }}
3434
condarc-file: ci/condarc.yml
3535
cache-env: true
3636
cache-downloads: true

.github/workflows/package-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-22.04
2121
strategy:
2222
matrix:
23-
extra: ["test", "performance", "timezone", "computation", "fss", "aws", "gcp", "excel", "parquet", "feather", "hdf5", "spss", "postgresql", "mysql", "sql-other", "html", "xml", "plot", "output_formatting", "clipboard", "compression", "all"]
23+
extra: ["test", "performance", "computation", "fss", "aws", "gcp", "excel", "parquet", "feather", "hdf5", "spss", "postgresql", "mysql", "sql-other", "html", "xml", "plot", "output_formatting", "clipboard", "compression", "all"]
2424
fail-fast: false
2525
name: Install Extras - ${{ matrix.extra }}
2626
concurrency:

ci/deps/actions-310-numpydev.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ dependencies:
1818
- python-dateutil
1919
- pytz
2020
- pip
21+
2122
- pip:
2223
- "cython"
2324
- "--extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple"
2425
- "--pre"
2526
- "numpy"
2627
- "scipy"
28+
- "tzdata>=2022.1"

ci/deps/actions-310.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ dependencies:
4949
- scipy>=1.7.1
5050
- sqlalchemy>=1.4.16
5151
- tabulate>=0.8.9
52-
- tzdata>=2022a
5352
- xarray>=0.21.0
5453
- xlrd>=2.0.1
5554
- xlsxwriter>=1.4.3
5655
- zstandard>=0.15.2
56+
57+
- pip:
58+
- tzdata>=2022.1

ci/deps/actions-311.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ dependencies:
4949
- scipy>=1.7.1
5050
- sqlalchemy>=1.4.16
5151
- tabulate>=0.8.9
52-
- tzdata>=2022a
5352
- xarray>=0.21.0
5453
- xlrd>=2.0.1
5554
- xlsxwriter>=1.4.3
5655
- zstandard>=0.15.2
56+
57+
- pip:
58+
- tzdata>=2022.1

ci/deps/actions-38-downstream_compat.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ dependencies:
6868
- pandas-gbq>=0.15.0
6969
- pyyaml
7070
- py
71+
72+
- pip:
73+
- tzdata>=2022.1

ci/deps/actions-38-minimum_versions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ dependencies:
5252
- scipy=1.7.1
5353
- sqlalchemy=1.4.16
5454
- tabulate=0.8.9
55-
- tzdata=2022a
5655
- xarray=0.21.0
5756
- xlrd=2.0.1
5857
- xlsxwriter=1.4.3
5958
- zstandard=0.15.2
6059

6160
- pip:
6261
- pyqt5==5.15.1
62+
- tzdata==2022.1

ci/deps/actions-38.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ dependencies:
5353
- xlrd>=2.0.1
5454
- xlsxwriter>=1.4.3
5555
- zstandard>=0.15.2
56+
57+
- pip:
58+
- tzdata>=2022.1

ci/deps/actions-39.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ dependencies:
4949
- scipy>=1.7.1
5050
- sqlalchemy>=1.4.16
5151
- tabulate>=0.8.9
52-
- tzdata>=2022a
5352
- xarray>=0.21.0
5453
- xlrd>=2.0.1
5554
- xlsxwriter>=1.4.3
5655
- zstandard>=0.15.2
56+
57+
- pip:
58+
- tzdata>=2022.1

ci/deps/actions-pypy-38.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ dependencies:
2222
- numpy
2323
- python-dateutil
2424
- pytz
25+
26+
- pip:
27+
- tzdata>=2022.1

ci/test_wheels_windows.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not ne
33
pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db'])
44

55
python --version
6-
pip install pytz six numpy python-dateutil
6+
pip install pytz six numpy python-dateutil tzdata>=2022.1
77
pip install hypothesis>=6.34.2 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17
88
pip install --find-links=pandas/dist --no-index pandas
99
python -c "%test_command%"

doc/source/getting_started/install.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -308,25 +308,6 @@ Dependency Minimum Version pip ext
308308
`numba <https://github.com/numba/numba>`__ 0.53.1 performance Alternative execution engine for operations that accept ``engine="numba"`` using a JIT compiler that translates Python functions to optimized machine code using the LLVM compiler.
309309
===================================================== ================== ================== ===================================================================================================================================================================================
310310

311-
Timezones
312-
^^^^^^^^^
313-
314-
Installable with ``pip install "pandas[timezone]"``
315-
316-
========================= ========================= =============== =============================================================
317-
Dependency Minimum Version pip extra Notes
318-
========================= ========================= =============== =============================================================
319-
tzdata 2022.1(pypi)/ timezone Allows the use of ``zoneinfo`` timezones with pandas.
320-
2022a(for system tzdata) **Note**: You only need to install the pypi package if your
321-
system does not already provide the IANA tz database.
322-
However, the minimum tzdata version still applies, even if it
323-
is not enforced through an error.
324-
325-
If you would like to keep your system tzdata version updated,
326-
it is recommended to use the ``tzdata`` package from
327-
conda-forge.
328-
========================= ========================= =============== =============================================================
329-
330311
Visualization
331312
^^^^^^^^^^^^^
332313

doc/source/user_guide/copy_on_write.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ two subsequent indexing operations, e.g.
114114
The column ``foo`` is updated where the column ``bar`` is greater than 5.
115115
This violates the CoW principles though, because it would have to modify the
116116
view ``df["foo"]`` and ``df`` in one step. Hence, chained assignment will
117-
consistently never work and raise a ``ChainedAssignmentError`` with CoW enabled:
117+
consistently never work and raise a ``ChainedAssignmentError`` warning
118+
with CoW enabled:
118119

119120
.. ipython:: python
120-
:okexcept:
121+
:okwarning:
121122
122123
df = pd.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
123124
df["foo"][df["bar"] > 5] = 100

doc/source/whatsnew/v2.0.0.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When installing pandas using pip, sets of optional dependencies can also be inst
2525
pip install "pandas[performance, aws]>=2.0.0"
2626
2727
The available extras, found in the :ref:`installation guide<install.dependencies>`, are
28-
``[all, performance, computation, timezone, fss, aws, gcp, excel, parquet, feather, hdf5, spss, postgresql, mysql,
28+
``[all, performance, computation, fss, aws, gcp, excel, parquet, feather, hdf5, spss, postgresql, mysql,
2929
sql-other, html, xml, plot, output_formatting, clipboard, compression, test]`` (:issue:`39164`).
3030

3131
.. _whatsnew_200.enhancements.index_can_hold_numpy_numeric_dtypes:
@@ -191,12 +191,12 @@ Copy-on-Write improvements
191191
of those Series objects for the columns of the DataFrame (:issue:`50777`)
192192

193193
- Trying to set values using chained assignment (for example, ``df["a"][1:3] = 0``)
194-
will now always raise an exception when Copy-on-Write is enabled. In this mode,
194+
will now always raise an warning when Copy-on-Write is enabled. In this mode,
195195
chained assignment can never work because we are always setting into a temporary
196196
object that is the result of an indexing operation (getitem), which under
197197
Copy-on-Write always behaves as a copy. Thus, assigning through a chain
198198
can never update the original Series or DataFrame. Therefore, an informative
199-
error is raised to the user instead of silently doing nothing (:issue:`49467`)
199+
warning is raised to the user to avoid silently doing nothing (:issue:`49467`)
200200

201201
- :meth:`DataFrame.replace` will now respect the Copy-on-Write mechanism
202202
when ``inplace=True``.
@@ -650,6 +650,8 @@ If installed, we now require:
650650
+-------------------+-----------------+----------+---------+
651651
| python-dateutil | 2.8.2 | X | X |
652652
+-------------------+-----------------+----------+---------+
653+
| tzdata | 2022.1 | X | X |
654+
+-------------------+-----------------+----------+---------+
653655

654656
For `optional libraries <https://pandas.pydata.org/docs/getting_started/install.html>`_ the general recommendation is to use the latest version.
655657
The following table lists the lowest version per library that is currently being tested throughout the development of pandas.

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ dependencies:
5252
- scipy>=1.7.1
5353
- sqlalchemy>=1.4.16
5454
- tabulate>=0.8.9
55-
- tzdata>=2022a
5655
- xarray>=0.21.0
5756
- xlrd>=2.0.1
5857
- xlsxwriter>=1.4.3
@@ -119,3 +118,4 @@ dependencies:
119118
- pip:
120119
- sphinx-toggleprompt
121120
- typing_extensions; python_version<"3.11"
121+
- tzdata>=2022.1

pandas/_libs/tslibs/offsets.pyx

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,11 +2574,28 @@ cdef class MonthBegin(MonthOffset):
25742574
"""
25752575
DateOffset of one month at beginning.
25762576
2577+
MonthBegin goes to the next date which is a start of the month.
2578+
To get the start of the current month pass the parameter n equals 0.
2579+
2580+
See Also
2581+
--------
2582+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
2583+
25772584
Examples
25782585
--------
2579-
>>> ts = pd.Timestamp(2022, 1, 1)
2586+
>>> ts = pd.Timestamp(2022, 11, 30)
2587+
>>> ts + pd.offsets.MonthBegin()
2588+
Timestamp('2022-12-01 00:00:00')
2589+
2590+
>>> ts = pd.Timestamp(2022, 12, 1)
25802591
>>> ts + pd.offsets.MonthBegin()
2581-
Timestamp('2022-02-01 00:00:00')
2592+
Timestamp('2023-01-01 00:00:00')
2593+
2594+
If you want to get the start of the current month pass the parameter n equals 0:
2595+
2596+
>>> ts = pd.Timestamp(2022, 12, 1)
2597+
>>> ts + pd.offsets.MonthBegin(0)
2598+
Timestamp('2022-12-01 00:00:00')
25822599
"""
25832600
_prefix = "MS"
25842601
_day_opt = "start"
@@ -2616,16 +2633,26 @@ cdef class BusinessMonthBegin(MonthOffset):
26162633
"""
26172634
DateOffset of one month at the first business day.
26182635
2636+
BusinessMonthBegin goes to the next date which is the first business day
2637+
of the month. To get the first business day of the current month pass
2638+
the parameter n equals 0.
2639+
26192640
Examples
26202641
--------
2621-
>>> from pandas.tseries.offsets import BMonthBegin
2622-
>>> ts=pd.Timestamp('2020-05-24 05:01:15')
2623-
>>> ts + BMonthBegin()
2624-
Timestamp('2020-06-01 05:01:15')
2625-
>>> ts + BMonthBegin(2)
2626-
Timestamp('2020-07-01 05:01:15')
2627-
>>> ts + BMonthBegin(-3)
2628-
Timestamp('2020-03-02 05:01:15')
2642+
>>> ts = pd.Timestamp(2022, 11, 30)
2643+
>>> ts + pd.offsets.BMonthBegin()
2644+
Timestamp('2022-12-01 00:00:00')
2645+
2646+
>>> ts = pd.Timestamp(2022, 12, 1)
2647+
>>> ts + pd.offsets.BMonthBegin()
2648+
Timestamp('2023-01-02 00:00:00')
2649+
2650+
If you want to get the start of the current business month pass
2651+
the parameter n equals 0:
2652+
2653+
>>> ts = pd.Timestamp(2022, 12, 1)
2654+
>>> ts + pd.offsets.BMonthBegin(0)
2655+
Timestamp('2022-12-01 00:00:00')
26292656
"""
26302657
_prefix = "BMS"
26312658
_day_opt = "business_start"
@@ -3671,7 +3698,9 @@ cdef class Easter(SingleConstructorOffset):
36713698

36723699
cdef class CustomBusinessDay(BusinessDay):
36733700
"""
3674-
DateOffset subclass representing custom business days excluding holidays.
3701+
DateOffset subclass representing possibly n custom business days.
3702+
3703+
In CustomBusinessDay we can use custom weekmask, holidays, and calendar.
36753704
36763705
Parameters
36773706
----------
@@ -3685,13 +3714,50 @@ cdef class CustomBusinessDay(BusinessDay):
36853714
List/array of dates to exclude from the set of valid business days,
36863715
passed to ``numpy.busdaycalendar``.
36873716
calendar : np.busdaycalendar
3717+
Calendar to integrate.
36883718
offset : timedelta, default timedelta(0)
3719+
Time offset to apply.
36893720
36903721
Examples
36913722
--------
3692-
>>> ts = pd.Timestamp(2022, 8, 5)
3693-
>>> ts + pd.offsets.CustomBusinessDay(1)
3694-
Timestamp('2022-08-08 00:00:00')
3723+
In the example below the default parameters give the next business day.
3724+
3725+
>>> ts = pd.Timestamp(2022, 8, 5, 16)
3726+
>>> ts + pd.offsets.CustomBusinessDay()
3727+
Timestamp('2022-08-08 16:00:00')
3728+
3729+
Business days can be specified by ``weekmask`` parameter. To convert
3730+
the returned datetime object to its string representation
3731+
the function strftime() is used in the next example.
3732+
3733+
>>> import datetime as dt
3734+
>>> freq = pd.offsets.CustomBusinessDay(weekmask="Mon Wed Fri")
3735+
>>> pd.date_range(dt.datetime(2022, 12, 10), dt.datetime(2022, 12, 21),
3736+
... freq=freq).strftime('%a %d %b %Y %H:%M')
3737+
Index(['Mon 12 Dec 2022 00:00', 'Wed 14 Dec 2022 00:00',
3738+
'Fri 16 Dec 2022 00:00', 'Mon 19 Dec 2022 00:00',
3739+
'Wed 21 Dec 2022 00:00'],
3740+
dtype='object')
3741+
3742+
Using NumPy business day calendar you can define custom holidays.
3743+
3744+
>>> import datetime as dt
3745+
>>> bdc = np.busdaycalendar(holidays=['2022-12-12', '2022-12-14'])
3746+
>>> freq = pd.offsets.CustomBusinessDay(calendar=bdc)
3747+
>>> pd.date_range(dt.datetime(2022, 12, 10), dt.datetime(2022, 12, 25), freq=freq)
3748+
DatetimeIndex(['2022-12-13', '2022-12-15', '2022-12-16', '2022-12-19',
3749+
'2022-12-20', '2022-12-21', '2022-12-22', '2022-12-23'],
3750+
dtype='datetime64[ns]', freq='C')
3751+
3752+
If you want to shift the result on n day you can use the parameter ``offset``.
3753+
3754+
>>> pd.Timestamp(2022, 8, 5, 16) + pd.offsets.CustomBusinessDay(1)
3755+
Timestamp('2022-08-08 16:00:00')
3756+
3757+
>>> import datetime as dt
3758+
>>> ts = pd.Timestamp(2022, 8, 5, 16)
3759+
>>> ts + pd.offsets.CustomBusinessDay(1, offset=dt.timedelta(days=1))
3760+
Timestamp('2022-08-09 16:00:00')
36953761
"""
36963762

36973763
_prefix = "C"

pandas/_testing/contexts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ def raises_chained_assignment_error():
211211

212212
return nullcontext()
213213
else:
214-
import pytest
214+
from pandas._testing import assert_produces_warning
215215

216-
return pytest.raises(
216+
return assert_produces_warning(
217217
ChainedAssignmentError,
218218
match=(
219219
"A value is trying to be set on a copy of a DataFrame or Series "

pandas/_typing.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@
131131
# Series is passed into a function, a Series is always returned and if a DataFrame is
132132
# passed in, a DataFrame is always returned.
133133
NDFrameT = TypeVar("NDFrameT", bound="NDFrame")
134-
# same as NDFrameT, needed when binding two pairs of parameters to potentially
135-
# separate NDFrame-subclasses (see NDFrame.align)
136-
NDFrameTb = TypeVar("NDFrameTb", bound="NDFrame")
137134

138135
NumpyIndexT = TypeVar("NumpyIndexT", np.ndarray, "Index")
139136

0 commit comments

Comments
 (0)