Skip to content

Commit 4cf2922

Browse files
Merge branch 'main' into pandas.Series.str.index
2 parents 0e5549b + 0cdc6a4 commit 4cf2922

File tree

107 files changed

+756
-344
lines changed

Some content is hidden

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

107 files changed

+756
-344
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
73-
-i "pandas.MultiIndex.get_loc_level PR07" \
7473
-i "pandas.MultiIndex.names SA01" \
7574
-i "pandas.MultiIndex.reorder_levels RT03,SA01" \
7675
-i "pandas.MultiIndex.sortlevel PR07,SA01" \
@@ -164,7 +163,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
164163
-i "pandas.Series.str.center RT03,SA01" \
165164
-i "pandas.Series.str.decode PR07,RT03,SA01" \
166165
-i "pandas.Series.str.encode PR07,RT03,SA01" \
167-
-i "pandas.Series.str.fullmatch RT03" \
168166
-i "pandas.Series.str.ljust RT03,SA01" \
169167
-i "pandas.Series.str.lower RT03" \
170168
-i "pandas.Series.str.lstrip RT03" \
@@ -283,12 +281,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
283281
-i "pandas.api.types.is_iterator PR07,SA01" \
284282
-i "pandas.api.types.is_list_like SA01" \
285283
-i "pandas.api.types.is_named_tuple PR07,SA01" \
286-
-i "pandas.api.types.is_numeric_dtype SA01" \
287284
-i "pandas.api.types.is_object_dtype SA01" \
288-
-i "pandas.api.types.is_period_dtype SA01" \
289285
-i "pandas.api.types.is_re PR07,SA01" \
290286
-i "pandas.api.types.is_re_compilable PR07,SA01" \
291-
-i "pandas.api.types.is_timedelta64_ns_dtype SA01" \
292287
-i "pandas.api.types.pandas_dtype PR07,RT03,SA01" \
293288
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \
294289
-i "pandas.arrays.BooleanArray SA01" \

doc/source/development/contributing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ If you are new to Git, you can reference some of these resources for learning Gi
7474
to the :ref:`contributor community <community>` for help if needed:
7575

7676
* `Git documentation <https://git-scm.com/doc>`_.
77-
* `Numpy's Git resources <https://numpy.org/doc/stable/dev/gitwash/git_resources.html>`_ tutorial.
7877

7978
Also, the project follows a forking workflow further described on this page whereby
8079
contributors fork the repository, make changes and then create a pull request.

doc/source/whatsnew/v3.0.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Other enhancements
5050
- :meth:`DataFrame.pivot_table` and :func:`pivot_table` now allow the passing of keyword arguments to ``aggfunc`` through ``**kwargs`` (:issue:`57884`)
5151
- :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`)
5252
- :meth:`Series.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`)
53+
- Multiplying two :class:`DateOffset` objects will now raise a ``TypeError`` instead of a ``RecursionError`` (:issue:`59442`)
5354
- Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`)
5455
- Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`)
5556
- Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`)
@@ -610,6 +611,7 @@ Groupby/resample/rolling
610611
- Bug in :meth:`DataFrameGroupBy.agg` that raises ``AttributeError`` when there is dictionary input and duplicated columns, instead of returning a DataFrame with the aggregation of all duplicate columns. (:issue:`55041`)
611612
- Bug in :meth:`DataFrameGroupBy.apply` that was returning a completely empty DataFrame when all return values of ``func`` were ``None`` instead of returning an empty DataFrame with the original columns and dtypes. (:issue:`57775`)
612613
- Bug in :meth:`DataFrameGroupBy.apply` with ``as_index=False`` that was returning :class:`MultiIndex` instead of returning :class:`Index`. (:issue:`58291`)
614+
- Bug in :meth:`DataFrameGroupBy.cumsum` and :meth:`DataFrameGroupBy.cumprod` where ``numeric_only`` parameter was passed indirectly through kwargs instead of passing directly. (:issue:`58811`)
613615
- Bug in :meth:`DataFrameGroupBy.cumsum` where it did not return the correct dtype when the label contained ``None``. (:issue:`58811`)
614616
- Bug in :meth:`DataFrameGroupby.transform` and :meth:`SeriesGroupby.transform` with a reducer and ``observed=False`` that coerces dtype to float when there are unobserved categories. (:issue:`55326`)
615617
- Bug in :meth:`Rolling.apply` where the applied function could be called on fewer than ``min_period`` periods if ``method="table"``. (:issue:`58868`)

pandas/_libs/lib.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,7 @@ def maybe_convert_objects(ndarray[object] objects,
27022702
if using_string_dtype() and is_string_array(objects, skipna=True):
27032703
from pandas.core.arrays.string_ import StringDtype
27042704

2705-
dtype = StringDtype(storage="pyarrow", na_value=np.nan)
2705+
dtype = StringDtype(na_value=np.nan)
27062706
return dtype.construct_array_type()._from_sequence(objects, dtype=dtype)
27072707

27082708
elif convert_to_nullable_dtype and is_string_array(objects, skipna=True):

pandas/_libs/tslibs/offsets.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ cdef class BaseOffset:
491491
elif is_integer_object(other):
492492
return type(self)(n=other * self.n, normalize=self.normalize,
493493
**self.kwds)
494+
elif isinstance(other, BaseOffset):
495+
# Otherwise raises RecurrsionError due to __rmul__
496+
raise TypeError(
497+
f"Cannot multiply {type(self).__name__} with "
498+
f"{type(other).__name__}."
499+
)
494500
return NotImplemented
495501

496502
def __rmul__(self, other):

pandas/_testing/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import numpy as np
1414

15+
from pandas._config import using_string_dtype
1516
from pandas._config.localization import (
1617
can_set_locale,
1718
get_locales,
@@ -106,7 +107,10 @@
106107
ALL_FLOAT_DTYPES: list[Dtype] = [*FLOAT_NUMPY_DTYPES, *FLOAT_EA_DTYPES]
107108

108109
COMPLEX_DTYPES: list[Dtype] = [complex, "complex64", "complex128"]
109-
STRING_DTYPES: list[Dtype] = [str, "str", "U"]
110+
if using_string_dtype():
111+
STRING_DTYPES: list[Dtype] = [str, "U"]
112+
else:
113+
STRING_DTYPES: list[Dtype] = [str, "str", "U"] # type: ignore[no-redef]
110114
COMPLEX_FLOAT_DTYPES: list[Dtype] = [*COMPLEX_DTYPES, *FLOAT_NUMPY_DTYPES]
111115

112116
DATETIME64_DTYPES: list[Dtype] = ["datetime64[ns]", "M8[ns]"]

pandas/_testing/asserters.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,24 @@ def assert_extension_array_equal(
796796
left_na, right_na, obj=f"{obj} NA mask", index_values=index_values
797797
)
798798

799+
# Specifically for StringArrayNumpySemantics, validate here we have a valid array
800+
if (
801+
isinstance(left.dtype, StringDtype)
802+
and left.dtype.storage == "python"
803+
and left.dtype.na_value is np.nan
804+
):
805+
assert np.all(
806+
[np.isnan(val) for val in left._ndarray[left_na]] # type: ignore[attr-defined]
807+
), "wrong missing value sentinels"
808+
if (
809+
isinstance(right.dtype, StringDtype)
810+
and right.dtype.storage == "python"
811+
and right.dtype.na_value is np.nan
812+
):
813+
assert np.all(
814+
[np.isnan(val) for val in right._ndarray[right_na]] # type: ignore[attr-defined]
815+
), "wrong missing value sentinels"
816+
799817
left_valid = left[~left_na].to_numpy(dtype=object)
800818
right_valid = right[~right_na].to_numpy(dtype=object)
801819
if check_exact:
@@ -1158,7 +1176,10 @@ def assert_frame_equal(
11581176
Specify how to compare internal data. If False, compare by columns.
11591177
If True, compare by blocks.
11601178
check_exact : bool, default False
1161-
Whether to compare number exactly.
1179+
Whether to compare number exactly. If False, the comparison uses the
1180+
relative tolerance (``rtol``) and absolute tolerance (``atol``)
1181+
parameters to determine if two values are considered close,
1182+
according to the formula: ``|a - b| <= (atol + rtol * |b|)``.
11621183
11631184
.. versionchanged:: 2.2.0
11641185

pandas/compat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626
from pandas.compat.numpy import is_numpy_dev
2727
from pandas.compat.pyarrow import (
28+
HAS_PYARROW,
2829
pa_version_under10p1,
2930
pa_version_under11p0,
3031
pa_version_under13p0,
@@ -156,6 +157,7 @@ def is_ci_environment() -> bool:
156157
"pa_version_under14p1",
157158
"pa_version_under16p0",
158159
"pa_version_under17p0",
160+
"HAS_PYARROW",
159161
"IS64",
160162
"ISMUSL",
161163
"PY311",

pandas/compat/pyarrow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
pa_version_under15p0 = _palv < Version("15.0.0")
1818
pa_version_under16p0 = _palv < Version("16.0.0")
1919
pa_version_under17p0 = _palv < Version("17.0.0")
20+
HAS_PYARROW = True
2021
except ImportError:
2122
pa_version_under10p1 = True
2223
pa_version_under11p0 = True
@@ -27,3 +28,4 @@
2728
pa_version_under15p0 = True
2829
pa_version_under16p0 = True
2930
pa_version_under17p0 = True
31+
HAS_PYARROW = False

pandas/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ def string_storage(request):
13131313
("python", pd.NA),
13141314
pytest.param(("pyarrow", pd.NA), marks=td.skip_if_no("pyarrow")),
13151315
pytest.param(("pyarrow", np.nan), marks=td.skip_if_no("pyarrow")),
1316+
("python", np.nan),
13161317
]
13171318
)
13181319
def string_dtype_arguments(request):
@@ -1374,12 +1375,14 @@ def object_dtype(request):
13741375
("python", pd.NA),
13751376
pytest.param(("pyarrow", pd.NA), marks=td.skip_if_no("pyarrow")),
13761377
pytest.param(("pyarrow", np.nan), marks=td.skip_if_no("pyarrow")),
1378+
("python", np.nan),
13771379
],
13781380
ids=[
13791381
"string=object",
13801382
"string=string[python]",
13811383
"string=string[pyarrow]",
13821384
"string=str[pyarrow]",
1385+
"string=str[python]",
13831386
],
13841387
)
13851388
def any_string_dtype(request):
@@ -1389,6 +1392,7 @@ def any_string_dtype(request):
13891392
* 'string[python]' (NA variant)
13901393
* 'string[pyarrow]' (NA variant)
13911394
* 'str' (NaN variant, with pyarrow)
1395+
* 'str' (NaN variant, without pyarrow)
13921396
"""
13931397
if isinstance(request.param, np.dtype):
13941398
return request.param

0 commit comments

Comments
 (0)