From a0b8c7ce915a66a9c19a68eb91cc3946432a2850 Mon Sep 17 00:00:00 2001 From: Brock Date: Thu, 16 Oct 2025 10:35:17 -0700 Subject: [PATCH] DEPR: remove string_pyarrow option --- doc/source/whatsnew/v3.0.0.rst | 1 + pandas/core/arrays/string_.py | 18 ------------------ pandas/core/config_init.py | 6 ------ pandas/tests/arrays/string_/test_string.py | 8 -------- pandas/tests/extension/test_string.py | 3 +-- 5 files changed, 2 insertions(+), 34 deletions(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 0045fc7b9c221..edfdac08ddee8 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -874,6 +874,7 @@ Other Removals - Removed the ``method`` keyword in ``ExtensionArray.fillna``, implement ``ExtensionArray._pad_or_backfill`` instead (:issue:`53621`) - Removed the attribute ``dtypes`` from :class:`.DataFrameGroupBy` (:issue:`51997`) - 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`) +- Enforced deprecation of storage option "pyarrow_numpy" for :class:`StringDtype` (:issue:`60152`) - Removed specifying ``include_groups=True`` in :class:`.DataFrameGroupBy.apply` and :class:`.Resampler.apply` (:issue:`7155`) .. --------------------------------------------------------------------------- diff --git a/pandas/core/arrays/string_.py b/pandas/core/arrays/string_.py index 9b4185959e660..efcfddbebb0d4 100644 --- a/pandas/core/arrays/string_.py +++ b/pandas/core/arrays/string_.py @@ -167,21 +167,6 @@ def __init__( else: storage = "python" - if storage == "pyarrow_numpy": - # TODO: Enforce in 3.0 (#60152) - warnings.warn( - "The 'pyarrow_numpy' storage option name is deprecated and will be " - 'removed in pandas 3.0. Use \'pd.StringDtype(storage="pyarrow", ' - "na_value=np.nan)' to construct the same dtype.\nOr enable the " - "'pd.options.future.infer_string = True' option globally and use " - 'the "str" alias as a shorthand notation to specify a dtype ' - '(instead of "string[pyarrow_numpy]").', - FutureWarning, # pdlint: ignore[warning_class] - stacklevel=find_stack_level(), - ) - storage = "pyarrow" - na_value = np.nan - # validate options if storage not in {"python", "pyarrow"}: raise ValueError( @@ -280,9 +265,6 @@ def construct_from_string(cls, string) -> Self: return cls(storage="python") elif string == "string[pyarrow]": return cls(storage="pyarrow") - elif string == "string[pyarrow_numpy]": - # this is deprecated in the dtype __init__, remove this in pandas 3.0 - return cls(storage="pyarrow_numpy") else: raise TypeError(f"Cannot construct a '{cls.__name__}' from '{string}'") diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index 785949987cfce..83015f4007793 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -478,12 +478,6 @@ def is_valid_string_storage(value: Any) -> None: legal_values = ["auto", "python", "pyarrow"] if value not in legal_values: msg = "Value must be one of python|pyarrow" - if value == "pyarrow_numpy": - # TODO: we can remove extra message after 3.0 - msg += ( - ". 'pyarrow_numpy' was specified, but this option should be " - "enabled using pandas.options.future.infer_string instead" - ) raise ValueError(msg) diff --git a/pandas/tests/arrays/string_/test_string.py b/pandas/tests/arrays/string_/test_string.py index d3effb7c33457..04abfafde6995 100644 --- a/pandas/tests/arrays/string_/test_string.py +++ b/pandas/tests/arrays/string_/test_string.py @@ -61,14 +61,6 @@ def string_dtype_highest_priority(dtype1, dtype2): return DTYPE_HIERARCHY[max(h1, h2)] -def test_dtype_constructor(): - pytest.importorskip("pyarrow") - - with tm.assert_produces_warning(FutureWarning): - dtype = pd.StringDtype("pyarrow_numpy") - assert dtype == pd.StringDtype("pyarrow", na_value=np.nan) - - def test_dtype_equality(): pytest.importorskip("pyarrow") diff --git a/pandas/tests/extension/test_string.py b/pandas/tests/extension/test_string.py index e373ff12c4086..45d1e30648423 100644 --- a/pandas/tests/extension/test_string.py +++ b/pandas/tests/extension/test_string.py @@ -116,8 +116,7 @@ def test_eq_with_str(self, dtype): # only the NA-variant supports parametrized string alias assert dtype == f"string[{dtype.storage}]" elif dtype.storage == "pyarrow": - with tm.assert_produces_warning(FutureWarning): - assert dtype == "string[pyarrow_numpy]" + assert dtype == "str" def test_is_not_string_type(self, dtype): # Different from BaseDtypeTests.test_is_not_string_type