Skip to content

Commit

Permalink
BUG (string dtype): correctly enable idxmin/max for python-storage st…
Browse files Browse the repository at this point in the history
…rings
  • Loading branch information
jorisvandenbossche committed Nov 8, 2024
1 parent feb183c commit 64c4beb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion pandas/core/arrays/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def _reduce(
else:
return nanops.nanall(self._ndarray, skipna=skipna)

if name in ["min", "max", "sum"]:
if name in ["min", "max", "argmin", "argmax", "sum"]:
result = getattr(self, name)(skipna=skipna, axis=axis, **kwargs)
if keepdims:
return self._from_sequence([result], dtype=self.dtype)
Expand Down
5 changes: 0 additions & 5 deletions pandas/tests/frame/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import (
IS64,
is_platform_windows,
Expand Down Expand Up @@ -1081,7 +1079,6 @@ def test_idxmin_empty(self, index, skipna, axis):
expected = Series(dtype=index.dtype)
tm.assert_series_equal(result, expected)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
@pytest.mark.parametrize("numeric_only", [True, False])
def test_idxmin_numeric_only(self, numeric_only):
df = DataFrame({"a": [2, 3, 1], "b": [2, 1, 1], "c": list("xyx")})
Expand All @@ -1098,7 +1095,6 @@ def test_idxmin_axis_2(self, float_frame):
with pytest.raises(ValueError, match=msg):
frame.idxmin(axis=2)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
@pytest.mark.parametrize("axis", [0, 1])
def test_idxmax(self, float_frame, int_frame, skipna, axis):
frame = float_frame
Expand Down Expand Up @@ -1132,7 +1128,6 @@ def test_idxmax_empty(self, index, skipna, axis):
expected = Series(dtype=index.dtype)
tm.assert_series_equal(result, expected)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
@pytest.mark.parametrize("numeric_only", [True, False])
def test_idxmax_numeric_only(self, numeric_only):
df = DataFrame({"a": [2, 3, 1], "b": [2, 1, 1], "c": list("xyx")})
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import HAS_PYARROW

import pandas as pd
from pandas import (
Categorical,
Expand Down Expand Up @@ -1206,10 +1202,6 @@ def test_idxminmax_object_dtype(self, using_infer_string):
with pytest.raises(TypeError, match=msg):
ser3.idxmin(skipna=False)

# TODO(infer_string) implement argmin/max for python string dtype
@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
)
def test_idxminmax_object_frame(self):
# GH#4279
df = DataFrame([["zimm", 2.5], ["biff", 1.0], ["bid", 12.0]])
Expand Down

0 comments on commit 64c4beb

Please sign in to comment.