Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG (string dtype): correctly enable idxmin/max for python-storage strings #60242

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading