Skip to content

ENH: Move corrwith from transformation to reduction kernels in groupby.base #32294

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

Merged
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/groupby/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _gotitem(self, key, ndim, subset=None):
[
"all",
"any",
"corrwith",
"count",
"first",
"idxmax",
Expand Down Expand Up @@ -132,7 +133,6 @@ def _gotitem(self, key, ndim, subset=None):
[
"backfill",
"bfill",
"corrwith",
"cumcount",
"cummax",
"cummin",
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,9 @@ def test_series_groupby_on_2_categoricals_unobserved(
if reduction_func == "ngroup":
pytest.skip("ngroup is not truly a reduction")

if reduction_func == "corrwith": # GH 32293
pytest.xfail("TODO: implemented SeriesGroupBy.corrwith")

df = pd.DataFrame(
{
"cat_1": pd.Categorical(list("AABB"), categories=list("ABCD")),
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/groupby/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ def test_transform_transformation_func(transformation_func):
}
)

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

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

result = g.transform(func, *args)

Expand Down