Skip to content

Commit 3bb6ea9

Browse files
remove xfails
1 parent ab30d87 commit 3bb6ea9

File tree

5 files changed

+8
-26
lines changed

5 files changed

+8
-26
lines changed

pandas/core/arrays/string_arrow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,10 @@ def _reduce(
418418
return ArrowExtensionArray(arr)._reduce(
419419
name, skipna=skipna, keepdims=keepdims, **kwargs
420420
)
421-
422-
result = self._reduce_calc(name, skipna=skipna, keepdims=keepdims, **kwargs)
421+
if name in ("min", "max", "sum", "argmin", "argmax"):
422+
result = self._reduce_calc(name, skipna=skipna, keepdims=keepdims, **kwargs)
423+
else:
424+
raise TypeError(f"Cannot perform reduction '{name}' with string dtype")
423425
if name in ("argmin", "argmax") and isinstance(result, pa.Array):
424426
return self._convert_int_result(result)
425427
elif isinstance(result, pa.Array):

pandas/tests/apply/test_frame_apply.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
from pandas._config import using_string_dtype
88

9-
from pandas.compat import HAS_PYARROW
10-
119
from pandas.core.dtypes.dtypes import CategoricalDtype
1210

1311
import pandas as pd
@@ -1218,7 +1216,6 @@ def test_agg_with_name_as_column_name():
12181216
tm.assert_series_equal(result, expected)
12191217

12201218

1221-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
12221219
def test_agg_multiple_mixed():
12231220
# GH 20909
12241221
mdf = DataFrame(
@@ -1247,9 +1244,6 @@ def test_agg_multiple_mixed():
12471244
tm.assert_frame_equal(result, expected)
12481245

12491246

1250-
@pytest.mark.xfail(
1251-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
1252-
)
12531247
def test_agg_multiple_mixed_raises():
12541248
# GH 20909
12551249
mdf = DataFrame(
@@ -1347,7 +1341,6 @@ def test_named_agg_reduce_axis1_raises(float_frame):
13471341
float_frame.agg(row1=(name1, "sum"), row2=(name2, "max"), axis=axis)
13481342

13491343

1350-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
13511344
def test_nuiscance_columns():
13521345
# GH 15015
13531346
df = DataFrame(
@@ -1524,7 +1517,6 @@ def test_apply_datetime_tz_issue(engine, request):
15241517
tm.assert_series_equal(result, expected)
15251518

15261519

1527-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
15281520
@pytest.mark.parametrize("df", [DataFrame({"A": ["a", None], "B": ["c", "d"]})])
15291521
@pytest.mark.parametrize("method", ["min", "max", "sum"])
15301522
def test_mixed_column_raises(df, method, using_infer_string):

pandas/tests/groupby/aggregate/test_cython.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ def test_cython_agg_return_dict():
146146
tm.assert_series_equal(ts, expected)
147147

148148

149-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
150149
def test_cython_fail_agg():
151150
dr = bdate_range("1/1/2000", periods=50)
152151
ts = Series(["A", "B", "C", "D", "E"] * 10, index=dr)

pandas/tests/groupby/test_groupby.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
from pandas._config import using_string_dtype
1010

11-
from pandas.compat import HAS_PYARROW
1211
from pandas.errors import SpecificationError
1312
import pandas.util._test_decorators as td
1413

15-
from pandas.core.dtypes.common import is_string_dtype
16-
1714
import pandas as pd
1815
from pandas import (
1916
Categorical,
@@ -1408,23 +1405,15 @@ def g(group):
14081405
tm.assert_series_equal(result, expected)
14091406

14101407

1411-
# TODO harmonize error messages
1412-
@pytest.mark.xfail(
1413-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
1414-
)
14151408
@pytest.mark.parametrize("grouper", ["A", ["A", "B"]])
1416-
def test_set_group_name(df, grouper, using_infer_string):
1409+
def test_set_group_name(df, grouper):
14171410
def f(group):
14181411
assert group.name is not None
14191412
return group
14201413

14211414
def freduce(group):
14221415
assert group.name is not None
1423-
if using_infer_string and grouper == "A" and is_string_dtype(group.dtype):
1424-
with pytest.raises(TypeError, match="does not support"):
1425-
group.sum()
1426-
else:
1427-
return group.sum()
1416+
return group.sum()
14281417

14291418
def freducex(x):
14301419
return freduce(x)

pandas/tests/groupby/test_raises.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def func(x):
208208
getattr(gb, how)(func)
209209

210210

211-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
212211
@pytest.mark.parametrize("how", ["agg", "transform"])
213212
@pytest.mark.parametrize("groupby_func_np", [np.sum, np.mean])
214213
def test_groupby_raises_string_np(
@@ -225,7 +224,8 @@ def test_groupby_raises_string_np(
225224
np.sum: (None, ""),
226225
np.mean: (
227226
TypeError,
228-
"Could not convert string .* to numeric",
227+
"Could not convert string .* to numeric|"
228+
"Cannot perform reduction 'mean' with string dtype",
229229
),
230230
}[groupby_func_np]
231231
_call_and_check(klass, msg, how, gb, groupby_func_np, ())

0 commit comments

Comments
 (0)