Skip to content
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/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def curried(x):
curried, self._obj_with_exclusions, is_transform=is_transform
)

if self._selected_obj.ndim != 1 and self.axis != 1:
if self._selected_obj.ndim != 1 and self.axis != 1 and result.ndim != 1:
missing = self._obj_with_exclusions.columns.difference(result.columns)
if len(missing) > 0:
warn_dropping_nuisance_columns_deprecated(
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,3 +1505,15 @@ def test_groupby_empty_dataset(dtype, kwargs):
expected = df.groupby("A").B.describe(**kwargs).reset_index(drop=True).iloc[:0]
expected.index = Index([])
tm.assert_frame_equal(result, expected)


def test_corrwith_with_1_axis():
# GH 47723
df = DataFrame({"a": [1, 1, 2], "b": [3, 7, 4]})
result = df.groupby("a").corrwith(df, axis=1)
index = Index(
data=[(1, 0), (1, 1), (1, 2), (2, 2), (2, 0), (2, 1)],
name=("a", None),
)
expected = Series([np.nan] * 6, index=index)
tm.assert_series_equal(result, expected)