Skip to content

Commit c098397

Browse files
WillAydrhshadrach
andauthored
Backport PR #60711: TST(string dtype): Resolve xfail in groupby.test_… (#60782)
Backport PR #60711: TST(string dtype): Resolve xfail in groupby.test_size Co-authored-by: Richard Shadrach <[email protected]>
1 parent 0b2cc22 commit c098397

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/tests/groupby/methods/test_size.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas.core.dtypes.common import is_integer_dtype
75

86
from pandas import (
@@ -108,18 +106,16 @@ def test_size_series_masked_type_returns_Int64(dtype):
108106
tm.assert_series_equal(result, expected)
109107

110108

111-
# TODO(infer_string) in case the column is object dtype, it should preserve that dtype
112-
# for the result's index
113-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
114-
def test_size_strings(any_string_dtype):
109+
def test_size_strings(any_string_dtype, using_infer_string):
115110
# GH#55627
116111
dtype = any_string_dtype
117112
df = DataFrame({"a": ["a", "a", "b"], "b": "a"}, dtype=dtype)
118113
result = df.groupby("a")["b"].size()
119114
exp_dtype = "Int64" if dtype == "string[pyarrow]" else "int64"
115+
exp_index_dtype = "str" if using_infer_string and dtype == "object" else dtype
120116
expected = Series(
121117
[2, 1],
122-
index=Index(["a", "b"], name="a", dtype=dtype),
118+
index=Index(["a", "b"], name="a", dtype=exp_index_dtype),
123119
name="b",
124120
dtype=exp_dtype,
125121
)

0 commit comments

Comments
 (0)