Skip to content

Commit 354b61f

Browse files
authored
TST(string dtype): Resolve xfail in groupby.test_size (#60711)
1 parent d38706a commit 354b61f

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 import (
75
DataFrame,
86
Index,
@@ -76,18 +74,16 @@ def test_size_series_masked_type_returns_Int64(dtype):
7674
tm.assert_series_equal(result, expected)
7775

7876

79-
# TODO(infer_string) in case the column is object dtype, it should preserve that dtype
80-
# for the result's index
81-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
82-
def test_size_strings(any_string_dtype):
77+
def test_size_strings(any_string_dtype, using_infer_string):
8378
# GH#55627
8479
dtype = any_string_dtype
8580
df = DataFrame({"a": ["a", "a", "b"], "b": "a"}, dtype=dtype)
8681
result = df.groupby("a")["b"].size()
8782
exp_dtype = "Int64" if dtype == "string[pyarrow]" else "int64"
83+
exp_index_dtype = "str" if using_infer_string and dtype == "object" else dtype
8884
expected = Series(
8985
[2, 1],
90-
index=Index(["a", "b"], name="a", dtype=dtype),
86+
index=Index(["a", "b"], name="a", dtype=exp_index_dtype),
9187
name="b",
9288
dtype=exp_dtype,
9389
)

0 commit comments

Comments
 (0)