Skip to content

Commit fbefd52

Browse files
authored
ENH: Add support for Index.min/max with arrow string (#51401)
1 parent 6db4c47 commit fbefd52

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ Other enhancements
308308
- :meth:`Series.dropna` and :meth:`DataFrame.dropna` has gained ``ignore_index`` keyword to reset index (:issue:`31725`)
309309
- Improved error message in :func:`to_datetime` for non-ISO8601 formats, informing users about the position of the first error (:issue:`50361`)
310310
- 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`)
311+
- Added support for :meth:`Index.min` and :meth:`Index.max` for pyarrow string dtypes (:issue:`51397`)
311312
- 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`)
312313
- 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`)
313314
- Added new argument ``dtype`` to :func:`read_sql` to be consistent with :func:`read_sql_query` (:issue:`50797`)

pandas/core/indexes/base.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -6928,8 +6928,7 @@ def min(self, axis=None, skipna: bool = True, *args, **kwargs):
69286928
return self._na_value
69296929

69306930
if not self._is_multi and not isinstance(self._values, np.ndarray):
6931-
# "ExtensionArray" has no attribute "min"
6932-
return self._values.min(skipna=skipna) # type: ignore[attr-defined]
6931+
return self._values._reduce(name="min", skipna=skipna)
69336932

69346933
return super().min(skipna=skipna)
69356934

@@ -6954,8 +6953,7 @@ def max(self, axis=None, skipna: bool = True, *args, **kwargs):
69546953
return self._na_value
69556954

69566955
if not self._is_multi and not isinstance(self._values, np.ndarray):
6957-
# "ExtensionArray" has no attribute "max"
6958-
return self._values.max(skipna=skipna) # type: ignore[attr-defined]
6956+
return self._values._reduce(name="max", skipna=skipna)
69596957

69606958
return super().max(skipna=skipna)
69616959

pandas/tests/indexes/test_numpy_compat.py

-4
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ def test_numpy_ufuncs_reductions(index, func, request):
158158
if len(index) == 0:
159159
return
160160

161-
if repr(index.dtype) == "string[pyarrow]":
162-
mark = pytest.mark.xfail(reason="ArrowStringArray has no min/max")
163-
request.node.add_marker(mark)
164-
165161
if isinstance(index, CategoricalIndex) and index.dtype.ordered is False:
166162
with pytest.raises(TypeError, match="is not ordered for"):
167163
func.reduce(index)

0 commit comments

Comments
 (0)