diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 75aec514031b4..14ae995d2fd57 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -308,6 +308,7 @@ Other enhancements - :meth:`Series.dropna` and :meth:`DataFrame.dropna` has gained ``ignore_index`` keyword to reset index (:issue:`31725`) - Improved error message in :func:`to_datetime` for non-ISO8601 formats, informing users about the position of the first error (:issue:`50361`) - Improved error message when trying to align :class:`DataFrame` objects (for example, in :func:`DataFrame.compare`) to clarify that "identically labelled" refers to both index and columns (:issue:`50083`) +- Added support for :meth:`Index.min` and :meth:`Index.max` for pyarrow string dtypes (:issue:`51397`) - Added :meth:`DatetimeIndex.as_unit` and :meth:`TimedeltaIndex.as_unit` to convert to different resolutions; supported resolutions are "s", "ms", "us", and "ns" (:issue:`50616`) - Added :meth:`Series.dt.unit` and :meth:`Series.dt.as_unit` to convert to different resolutions; supported resolutions are "s", "ms", "us", and "ns" (:issue:`51223`) - Added new argument ``dtype`` to :func:`read_sql` to be consistent with :func:`read_sql_query` (:issue:`50797`) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 6031bdc62c38a..31e34379fd373 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6928,8 +6928,7 @@ def min(self, axis=None, skipna: bool = True, *args, **kwargs): return self._na_value if not self._is_multi and not isinstance(self._values, np.ndarray): - # "ExtensionArray" has no attribute "min" - return self._values.min(skipna=skipna) # type: ignore[attr-defined] + return self._values._reduce(name="min", skipna=skipna) return super().min(skipna=skipna) @@ -6954,8 +6953,7 @@ def max(self, axis=None, skipna: bool = True, *args, **kwargs): return self._na_value if not self._is_multi and not isinstance(self._values, np.ndarray): - # "ExtensionArray" has no attribute "max" - return self._values.max(skipna=skipna) # type: ignore[attr-defined] + return self._values._reduce(name="max", skipna=skipna) return super().max(skipna=skipna) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index 788d03d5b7212..07ebe6fa04beb 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -158,10 +158,6 @@ def test_numpy_ufuncs_reductions(index, func, request): if len(index) == 0: return - if repr(index.dtype) == "string[pyarrow]": - mark = pytest.mark.xfail(reason="ArrowStringArray has no min/max") - request.node.add_marker(mark) - if isinstance(index, CategoricalIndex) and index.dtype.ordered is False: with pytest.raises(TypeError, match="is not ordered for"): func.reduce(index)