Skip to content

Commit 7ef7dd0

Browse files
fujiaxiangSeeminSyed
authored andcommitted
ENH: Move corrwith from transformation to reduction kernels in groupby.base (pandas-dev#32294)
1 parent 0f02f0c commit 7ef7dd0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pandas/core/groupby/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def _gotitem(self, key, ndim, subset=None):
9898
[
9999
"all",
100100
"any",
101+
"corrwith",
101102
"count",
102103
"first",
103104
"idxmax",
@@ -132,7 +133,6 @@ def _gotitem(self, key, ndim, subset=None):
132133
[
133134
"backfill",
134135
"bfill",
135-
"corrwith",
136136
"cumcount",
137137
"cummax",
138138
"cummin",

pandas/tests/groupby/test_categorical.py

+3
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,9 @@ def test_series_groupby_on_2_categoricals_unobserved(
12621262
if reduction_func == "ngroup":
12631263
pytest.skip("ngroup is not truly a reduction")
12641264

1265+
if reduction_func == "corrwith": # GH 32293
1266+
pytest.xfail("TODO: implemented SeriesGroupBy.corrwith")
1267+
12651268
df = pd.DataFrame(
12661269
{
12671270
"cat_1": pd.Categorical(list("AABB"), categories=list("ABCD")),

pandas/tests/groupby/test_transform.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ def test_transform_transformation_func(transformation_func):
327327
}
328328
)
329329

330-
if transformation_func in ["pad", "backfill", "tshift", "corrwith", "cumcount"]:
330+
if transformation_func in ["pad", "backfill", "tshift", "cumcount"]:
331331
# These transformation functions are not yet covered in this test
332-
pytest.xfail("See GH 31269 and GH 31270")
332+
pytest.xfail("See GH 31269")
333333
elif _is_numpy_dev and transformation_func in ["cummin"]:
334334
pytest.xfail("https://github.com/pandas-dev/pandas/issues/31992")
335335
elif transformation_func == "fillna":
@@ -1093,8 +1093,10 @@ def test_transform_agg_by_name(reduction_func, obj):
10931093
pytest.xfail("TODO: g.transform('ngroup') doesn't work")
10941094
if func == "size": # GH#27469
10951095
pytest.xfail("TODO: g.transform('size') doesn't work")
1096+
if func == "corrwith" and isinstance(obj, Series): # GH#32293
1097+
pytest.xfail("TODO: implement SeriesGroupBy.corrwith")
10961098

1097-
args = {"nth": [0], "quantile": [0.5]}.get(func, [])
1099+
args = {"nth": [0], "quantile": [0.5], "corrwith": [obj]}.get(func, [])
10981100

10991101
result = g.transform(func, *args)
11001102

0 commit comments

Comments
 (0)