Skip to content

Commit 5371ec9

Browse files
committed
Merge branch 'main' into enh-list-arith
2 parents 8c3d476 + 8d48f02 commit 5371ec9

File tree

29 files changed

+664
-408
lines changed

29 files changed

+664
-408
lines changed

.github/workflows/docbuild-and-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
run: mv doc/build/html web/build/docs
9494

9595
- name: Save website as an artifact
96-
uses: actions/upload-artifact@v4
96+
uses: actions/upload-artifact@v5
9797
with:
9898
name: website
9999
path: web/build

.github/workflows/wheels.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
python -m pip install build
6565
python -m build --sdist
6666
67-
- uses: actions/upload-artifact@v4
67+
- uses: actions/upload-artifact@v5
6868
with:
6969
name: sdist
7070
path: ./dist/*
@@ -138,7 +138,7 @@ jobs:
138138
# removes unnecessary files from the release
139139
- name: Download sdist (not macOS)
140140
#if: ${{ matrix.buildplat[1] != 'macosx_*' }}
141-
uses: actions/download-artifact@v5
141+
uses: actions/download-artifact@v6
142142
with:
143143
name: sdist
144144
path: ./dist
@@ -196,7 +196,7 @@ jobs:
196196
shell: bash -el {0}
197197
run: for whl in $(ls wheelhouse); do wheel unpack wheelhouse/$whl -d /tmp; done
198198

199-
- uses: actions/upload-artifact@v4
199+
- uses: actions/upload-artifact@v5
200200
with:
201201
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
202202
path: ./wheelhouse/*.whl
@@ -238,11 +238,11 @@ jobs:
238238

239239
steps:
240240
- name: Download all artefacts
241-
uses: actions/download-artifact@v5
241+
uses: actions/download-artifact@v6
242242
with:
243243
path: dist # everything lands in ./dist/**
244244

245-
# TODO: This step can be probably be achieved by actions/download-artifact@v5
245+
# TODO: This step can be probably be achieved by actions/download-artifact@v6
246246
# by specifying merge-multiple: true, and a glob pattern
247247
- name: Collect files
248248
run: |

doc/source/reference/aliases.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Alias Meaning
6565
:py:type:`NaPosition` Argument type for ``na_position`` in :meth:`sort_index` and :meth:`sort_values`
6666
:py:type:`NsmallestNlargestKeep` Argument type for ``keep`` in :meth:`nlargest` and :meth:`nsmallest`
6767
:py:type:`OpenFileErrors` Argument type for ``errors`` in :meth:`to_hdf` and :meth:`to_csv`
68-
:py:type:`Ordered` Return type for :py:attr:`ordered`` in :class:`CategoricalDtype` and :class:`Categorical`
68+
:py:type:`Ordered` Return type for :py:attr:`ordered` in :class:`CategoricalDtype` and :class:`Categorical`
6969
:py:type:`ParquetCompressionOptions` Argument type for ``compression`` in :meth:`DataFrame.to_parquet`
7070
:py:type:`QuantileInterpolation` Argument type for ``interpolation`` in :meth:`quantile`
7171
:py:type:`ReadBuffer` Additional argument type corresponding to buffers for various file reading methods
@@ -89,7 +89,7 @@ Alias Meaning
8989
:py:type:`ToTimestampHow` Argument type for ``how`` in :meth:`to_timestamp` and ``convention`` in :meth:`resample`
9090
:py:type:`UpdateJoin` Argument type for ``join`` in :meth:`DataFrame.update`
9191
:py:type:`UsecolsArgType` Argument type for ``usecols`` in :meth:`pandas.read_clipboard`, :meth:`pandas.read_csv` and :meth:`pandas.read_excel`
92-
:py:type:`WindowingRankType` Argument type for ``method`` in :meth:`rank`` in rolling and expanding window operations
92+
:py:type:`WindowingRankType` Argument type for ``method`` in :meth:`rank` in rolling and expanding window operations
9393
:py:type:`WriteBuffer` Additional argument type corresponding to buffers for various file output methods
9494
:py:type:`WriteExcelBuffer` Additional argument type corresponding to buffers for :meth:`to_excel`
9595
:py:type:`XMLParsers` Argument type for ``parser`` in :meth:`DataFrame.to_xml` and :meth:`pandas.read_xml`

doc/source/user_guide/io.rst

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,52 +2366,7 @@ Read a URL with no options:
23662366

23672367
The data from the above URL changes every Monday so the resulting data above may be slightly different.
23682368

2369-
Read a URL while passing headers alongside the HTTP request:
2370-
2371-
.. code-block:: ipython
2372-
2373-
In [322]: url = 'https://www.sump.org/notes/request/' # HTTP request reflector
2374-
2375-
In [323]: pd.read_html(url)
2376-
Out[323]:
2377-
[ 0 1
2378-
0 Remote Socket: 51.15.105.256:51760
2379-
1 Protocol Version: HTTP/1.1
2380-
2 Request Method: GET
2381-
3 Request URI: /notes/request/
2382-
4 Request Query: NaN,
2383-
0 Accept-Encoding: identity
2384-
1 Host: www.sump.org
2385-
2 User-Agent: Python-urllib/3.8
2386-
3 Connection: close]
2387-
2388-
In [324]: headers = {
2389-
.....: 'User-Agent':'Mozilla Firefox v14.0',
2390-
.....: 'Accept':'application/json',
2391-
.....: 'Connection':'keep-alive',
2392-
.....: 'Auth':'Bearer 2*/f3+fe68df*4'
2393-
.....: }
2394-
2395-
In [325]: pd.read_html(url, storage_options=headers)
2396-
Out[325]:
2397-
[ 0 1
2398-
0 Remote Socket: 51.15.105.256:51760
2399-
1 Protocol Version: HTTP/1.1
2400-
2 Request Method: GET
2401-
3 Request URI: /notes/request/
2402-
4 Request Query: NaN,
2403-
0 User-Agent: Mozilla Firefox v14.0
2404-
1 AcceptEncoding: gzip, deflate, br
2405-
2 Accept: application/json
2406-
3 Connection: keep-alive
2407-
4 Auth: Bearer 2*/f3+fe68df*4]
2408-
2409-
.. note::
2410-
2411-
We see above that the headers we passed are reflected in the HTTP request.
2412-
2413-
Read in the content of the file from the above URL and pass it to ``read_html``
2414-
as a string:
2369+
Read in HTML content from a file using ``read_html``:
24152370

24162371
.. ipython:: python
24172372

doc/source/whatsnew/v3.0.0.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ Datetimelike
981981
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` does not raise on Custom business days frequencies bigger then "1C" (:issue:`58664`)
982982
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` returning ``False`` on double-digit frequencies (:issue:`58523`)
983983
- Bug in :meth:`DatetimeIndex.union` and :meth:`DatetimeIndex.intersection` when ``unit`` was non-nanosecond (:issue:`59036`)
984+
- Bug in :meth:`DatetimeIndex.where` and :meth:`TimedeltaIndex.where` failing to set ``freq=None`` in some cases (:issue:`24555`)
984985
- Bug in :meth:`Index.union` with a ``pyarrow`` timestamp dtype incorrectly returning ``object`` dtype (:issue:`58421`)
985986
- Bug in :meth:`Series.dt.microsecond` producing incorrect results for pyarrow backed :class:`Series`. (:issue:`59154`)
986987
- Bug in :meth:`Timestamp.normalize` and :meth:`DatetimeArray.normalize` returning incorrect results instead of raising on integer overflow for very small (distant past) values (:issue:`60583`)
@@ -997,7 +998,6 @@ Datetimelike
997998
- Bug in constructing arrays with a timezone-aware :class:`ArrowDtype` from timezone-naive datetime objects incorrectly treating those as UTC times instead of wall times like :class:`DatetimeTZDtype` (:issue:`61775`)
998999
- Bug in setting scalar values with mismatched resolution into arrays with non-nanosecond ``datetime64``, ``timedelta64`` or :class:`DatetimeTZDtype` incorrectly truncating those scalars (:issue:`56410`)
9991000

1000-
10011001
Timedelta
10021002
^^^^^^^^^
10031003
- Accuracy improvement in :meth:`Timedelta.to_pytimedelta` to round microseconds consistently for large nanosecond based Timedelta (:issue:`57841`)
@@ -1036,6 +1036,7 @@ Conversion
10361036

10371037
Strings
10381038
^^^^^^^
1039+
- Bug in :meth:`Series.str.replace` raising an error on valid group references (``\1``, ``\2``, etc.) on series converted to PyArrow backend dtype (:issue:`62653`)
10391040
- Bug in :meth:`Series.str.zfill` raising ``AttributeError`` for :class:`ArrowDtype` (:issue:`61485`)
10401041
- Bug in :meth:`Series.value_counts` would not respect ``sort=False`` for series having ``string`` dtype (:issue:`55224`)
10411042
- Bug in multiplication with a :class:`StringDtype` incorrectly allowing multiplying by bools; explicitly cast to integers instead (:issue:`62595`)
@@ -1152,6 +1153,7 @@ Groupby/resample/rolling
11521153
- Bug in :meth:`.DataFrameGroupBy.groups` and :meth:`.SeriesGroupby.groups` that would not respect groupby argument ``dropna`` (:issue:`55919`)
11531154
- Bug in :meth:`.DataFrameGroupBy.median` where nat values gave an incorrect result. (:issue:`57926`)
11541155
- Bug in :meth:`.DataFrameGroupBy.quantile` when ``interpolation="nearest"`` is inconsistent with :meth:`DataFrame.quantile` (:issue:`47942`)
1156+
- Bug in :meth:`.DataFrameGroupBy` reductions where non-Boolean values were allowed for the ``numeric_only`` argument; passing a non-Boolean value will now raise (:issue:`62778`)
11551157
- Bug in :meth:`.Resampler.interpolate` on a :class:`DataFrame` with non-uniform sampling and/or indices not aligning with the resulting resampled index would result in wrong interpolation (:issue:`21351`)
11561158
- Bug in :meth:`.Series.rolling` when used with a :class:`.BaseIndexer` subclass and computing min/max (:issue:`46726`)
11571159
- Bug in :meth:`DataFrame.ewm` and :meth:`Series.ewm` when passed ``times`` and aggregation functions other than mean (:issue:`51695`)
@@ -1208,6 +1210,7 @@ ExtensionArray
12081210
- 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`)
12091211
- Bug in constructing pandas data structures when passing into ``dtype`` a string of the type followed by ``[pyarrow]`` while PyArrow is not installed would raise ``NameError`` rather than ``ImportError`` (:issue:`57928`)
12101212
- Bug in various :class:`DataFrame` reductions for pyarrow temporal dtypes returning incorrect dtype when result was null (:issue:`59234`)
1213+
- Fixed flex arithmetic with :class:`ExtensionArray` operands raising when ``fill_value`` was passed. (:issue:`62467`)
12111214

12121215
Styler
12131216
^^^^^^

pandas/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,9 @@ def any_string_dtype(request):
14471447
return pd.StringDtype(storage, na_value)
14481448

14491449

1450+
any_string_dtype2 = any_string_dtype
1451+
1452+
14501453
@pytest.fixture(params=tm.DATETIME64_DTYPES)
14511454
def datetime64_dtype(request):
14521455
"""

pandas/core/arrays/_arrow_string_mixins.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,12 @@ def _str_replace(
173173
or callable(repl)
174174
or not case
175175
or flags
176-
or (
177-
isinstance(repl, str)
178-
and (r"\g<" in repl or re.search(r"\\\d", repl) is not None)
179-
)
176+
or (isinstance(repl, str) and r"\g<" in repl)
180177
):
181178
raise NotImplementedError(
182179
"replace is not supported with a re.Pattern, callable repl, "
183180
"case=False, flags!=0, or when the replacement string contains "
184-
"named group references (\\g<...>, \\d+)"
181+
"named group references (\\g<...>)"
185182
)
186183

187184
func = pc.replace_substring_regex if regex else pc.replace_substring

pandas/core/arrays/datetimelike.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ def __getitem__(self, key: PositionalIndexer2D) -> Self | DTScalarOrNaT:
393393
else:
394394
# At this point we know the result is an array.
395395
result = cast(Self, result)
396-
result._freq = self._get_getitem_freq(key)
396+
# error: Incompatible types in assignment (expression has type
397+
# "BaseOffset | None", variable has type "None")
398+
result._freq = self._get_getitem_freq(key) # type: ignore[assignment]
397399
return result
398400

399401
def _get_getitem_freq(self, key) -> BaseOffset | None:
@@ -527,6 +529,10 @@ def view(self, dtype: Dtype | None = None) -> ArrayLike:
527529
# are present in this file.
528530
return super().view(dtype)
529531

532+
def _putmask(self, mask: npt.NDArray[np.bool_], value) -> None:
533+
super()._putmask(mask, value)
534+
self._freq = None # GH#24555
535+
530536
# ------------------------------------------------------------------
531537
# Validation Methods
532538
# TODO: try to de-duplicate these, ensure identical behavior
@@ -2042,7 +2048,7 @@ def _maybe_pin_freq(self, freq, validate_kwds: dict) -> None:
20422048
if self._freq is None:
20432049
# Set _freq directly to bypass duplicative _validate_frequency
20442050
# check.
2045-
self._freq = to_offset(self.inferred_freq)
2051+
self._freq = to_offset(self.inferred_freq) # type: ignore[assignment]
20462052
elif freq is lib.no_default:
20472053
# user did not specify anything, keep inferred freq if the original
20482054
# data had one, otherwise do nothing
@@ -2442,7 +2448,7 @@ def take(
24422448

24432449
if isinstance(maybe_slice, slice):
24442450
freq = self._get_getitem_freq(maybe_slice)
2445-
result._freq = freq
2451+
result._freq = freq # type: ignore[assignment]
24462452

24472453
return result
24482454

pandas/core/arrays/string_arrow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ def _str_replace(
425425
or flags
426426
or ( # substitution contains a named group pattern
427427
# https://docs.python.org/3/library/re.html
428-
isinstance(repl, str)
429-
and (r"\g<" in repl or re.search(r"\\\d", repl) is not None)
428+
isinstance(repl, str) and r"\g<" in repl
430429
)
431430
):
432431
return super()._str_replace(pat, repl, n, case, flags, regex)

pandas/core/frame.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11554,6 +11554,15 @@ def _dict_round(df: DataFrame, decimals) -> Iterator[Series]:
1155411554
def _series_round(ser: Series, decimals: int) -> Series:
1155511555
if is_integer_dtype(ser.dtype) or is_float_dtype(ser.dtype):
1155611556
return ser.round(decimals)
11557+
elif isinstance(ser._values, (DatetimeArray, TimedeltaArray, PeriodArray)):
11558+
# GH#57781
11559+
# TODO: also the ArrowDtype analogues?
11560+
warnings.warn(
11561+
"obj.round has no effect with datetime, timedelta, "
11562+
"or period dtypes. Use obj.dt.round(...) instead.",
11563+
UserWarning,
11564+
stacklevel=find_stack_level(),
11565+
)
1155711566
return ser
1155811567

1155911568
nv.validate_round(args, kwargs)

0 commit comments

Comments
 (0)