Skip to content

Commit c5ad86a

Browse files
committed
Merge branch 'main' into depr-select_dtypes-object
2 parents ef37e1d + 1f81f47 commit c5ad86a

File tree

8 files changed

+81
-42
lines changed

8 files changed

+81
-42
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ Other Removals
875875
- Removed the ``method`` keyword in ``ExtensionArray.fillna``, implement ``ExtensionArray._pad_or_backfill`` instead (:issue:`53621`)
876876
- Removed the attribute ``dtypes`` from :class:`.DataFrameGroupBy` (:issue:`51997`)
877877
- Enforced deprecation of ``argmin``, ``argmax``, ``idxmin``, and ``idxmax`` returning a result when ``skipna=False`` and an NA value is encountered or all values are NA values; these operations will now raise in such cases (:issue:`33941`, :issue:`51276`)
878+
- Enforced deprecation of storage option "pyarrow_numpy" for :class:`StringDtype` (:issue:`60152`)
878879
- Removed specifying ``include_groups=True`` in :class:`.DataFrameGroupBy.apply` and :class:`.Resampler.apply` (:issue:`7155`)
879880

880881
.. ---------------------------------------------------------------------------

pandas/core/arrays/string_.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,6 @@ def __init__(
167167
else:
168168
storage = "python"
169169

170-
if storage == "pyarrow_numpy":
171-
# TODO: Enforce in 3.0 (#60152)
172-
warnings.warn(
173-
"The 'pyarrow_numpy' storage option name is deprecated and will be "
174-
'removed in pandas 3.0. Use \'pd.StringDtype(storage="pyarrow", '
175-
"na_value=np.nan)' to construct the same dtype.\nOr enable the "
176-
"'pd.options.future.infer_string = True' option globally and use "
177-
'the "str" alias as a shorthand notation to specify a dtype '
178-
'(instead of "string[pyarrow_numpy]").',
179-
FutureWarning, # pdlint: ignore[warning_class]
180-
stacklevel=find_stack_level(),
181-
)
182-
storage = "pyarrow"
183-
na_value = np.nan
184-
185170
# validate options
186171
if storage not in {"python", "pyarrow"}:
187172
raise ValueError(
@@ -280,9 +265,6 @@ def construct_from_string(cls, string) -> Self:
280265
return cls(storage="python")
281266
elif string == "string[pyarrow]":
282267
return cls(storage="pyarrow")
283-
elif string == "string[pyarrow_numpy]":
284-
# this is deprecated in the dtype __init__, remove this in pandas 3.0
285-
return cls(storage="pyarrow_numpy")
286268
else:
287269
raise TypeError(f"Cannot construct a '{cls.__name__}' from '{string}'")
288270

pandas/core/config_init.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,6 @@ def is_valid_string_storage(value: Any) -> None:
478478
legal_values = ["auto", "python", "pyarrow"]
479479
if value not in legal_values:
480480
msg = "Value must be one of python|pyarrow"
481-
if value == "pyarrow_numpy":
482-
# TODO: we can remove extra message after 3.0
483-
msg += (
484-
". 'pyarrow_numpy' was specified, but this option should be "
485-
"enabled using pandas.options.future.infer_string instead"
486-
)
487481
raise ValueError(msg)
488482

489483

pandas/core/ops/docstrings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,10 @@ def make_flex_doc(op_name: str, typ: str) -> str:
435435
436436
Parameters
437437
----------
438-
other : Series or scalar value
439-
The second operand in this operation.
438+
other : object
439+
When a Series is provided, will align on indexes. For all other types,
440+
will behave the same as ``==`` but with possibly different results due
441+
to the other arguments.
440442
level : int or name
441443
Broadcast across a level, matching Index values on the
442444
passed MultiIndex level.

pandas/core/series.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6092,8 +6092,10 @@ def eq(
60926092
60936093
Parameters
60946094
----------
6095-
other : Series or scalar value
6096-
The second operand in this operation.
6095+
other : object
6096+
When a Series is provided, will align on indexes. For all other types,
6097+
will behave the same as ``==`` but with possibly different results due
6098+
to the other arguments.
60976099
level : int or name
60986100
Broadcast across a level, matching Index values on the
60996101
passed MultiIndex level.
@@ -6161,8 +6163,10 @@ def le(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
61616163
61626164
Parameters
61636165
----------
6164-
other : Series or scalar value
6165-
The second operand in this operation.
6166+
other : object
6167+
When a Series is provided, will align on indexes. For all other types,
6168+
will behave the same as ``==`` but with possibly different results due
6169+
to the other arguments.
61666170
level : int or name
61676171
Broadcast across a level, matching Index values on the
61686172
passed MultiIndex level.
@@ -6233,8 +6237,10 @@ def ge(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series:
62336237
62346238
Parameters
62356239
----------
6236-
other : Series or scalar value
6237-
The second operand in this operation.
6240+
other : object
6241+
When a Series is provided, will align on indexes. For all other types,
6242+
will behave the same as ``==`` but with possibly different results due
6243+
to the other arguments.
62386244
level : int or name
62396245
Broadcast across a level, matching Index values on the
62406246
passed MultiIndex level.

pandas/tests/arrays/string_/test_string.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ def string_dtype_highest_priority(dtype1, dtype2):
6161
return DTYPE_HIERARCHY[max(h1, h2)]
6262

6363

64-
def test_dtype_constructor():
65-
pytest.importorskip("pyarrow")
66-
67-
with tm.assert_produces_warning(FutureWarning):
68-
dtype = pd.StringDtype("pyarrow_numpy")
69-
assert dtype == pd.StringDtype("pyarrow", na_value=np.nan)
70-
71-
7264
def test_dtype_equality():
7365
pytest.importorskip("pyarrow")
7466

pandas/tests/extension/test_string.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ def test_eq_with_str(self, dtype):
116116
# only the NA-variant supports parametrized string alias
117117
assert dtype == f"string[{dtype.storage}]"
118118
elif dtype.storage == "pyarrow":
119-
with tm.assert_produces_warning(FutureWarning):
120-
assert dtype == "string[pyarrow_numpy]"
119+
assert dtype == "str"
121120

122121
def test_is_not_string_type(self, dtype):
123122
# Different from BaseDtypeTests.test_is_not_string_type

pandas/tests/series/methods/test_compare.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
from enum import (
2+
Enum,
3+
auto,
4+
)
5+
16
import numpy as np
27
import pytest
38

@@ -138,3 +143,61 @@ def test_compare_datetime64_and_string():
138143
tm.assert_series_equal(result_eq1, expected_eq)
139144
tm.assert_series_equal(result_eq2, expected_eq)
140145
tm.assert_series_equal(result_neq, expected_neq)
146+
147+
148+
def test_eq_objects():
149+
# GH#62191 Test eq with Enum and List elements
150+
151+
class Thing(Enum):
152+
FIRST = auto()
153+
SECOND = auto()
154+
155+
left = pd.Series([Thing.FIRST, Thing.SECOND])
156+
py_l = [Thing.FIRST, Thing.SECOND]
157+
158+
result = left.eq(Thing.FIRST)
159+
expected = pd.Series([True, False])
160+
tm.assert_series_equal(result, expected)
161+
162+
result = left.eq(py_l)
163+
expected = pd.Series([True, True])
164+
tm.assert_series_equal(result, expected)
165+
166+
result = left.eq(np.asarray(py_l))
167+
expected = pd.Series([True, True])
168+
tm.assert_series_equal(result, expected)
169+
170+
result = left.eq(pd.Series(py_l))
171+
expected = pd.Series([True, True])
172+
tm.assert_series_equal(result, expected)
173+
174+
result = pd.Series([[1, 2], [3, 4]]).eq([1, 2])
175+
expected = pd.Series([True, False])
176+
with pytest.raises(AssertionError):
177+
tm.assert_series_equal(result, expected)
178+
expected = pd.Series([False, False])
179+
tm.assert_series_equal(result, expected)
180+
181+
182+
def test_eq_with_index():
183+
# GH#62191 Test eq with non-trivial indices
184+
left = pd.Series([1, 2], index=[1, 0])
185+
py_l = [1, 2]
186+
187+
# assuming Python list has the same index as the Series
188+
result = left.eq(py_l)
189+
expected = pd.Series([True, True], index=[1, 0])
190+
tm.assert_series_equal(result, expected)
191+
192+
# assuming np.ndarray has the same index as the Series
193+
result = left.eq(np.asarray(py_l))
194+
expected = pd.Series([True, True], index=[1, 0])
195+
tm.assert_series_equal(result, expected)
196+
197+
result = left.eq(pd.Series(py_l))
198+
expected = pd.Series([False, False])
199+
tm.assert_series_equal(result, expected)
200+
201+
result = left.eq(pd.Series([2, 1]))
202+
expected = pd.Series([True, True])
203+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)