Skip to content

Commit 2e77cef

Browse files
committed
TST: groupby apply with indexing and colunm aggregation returns the column (pandas-dev#7002)
1 parent 24857a2 commit 2e77cef

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/groupby/test_apply.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,3 +961,13 @@ def fn(x):
961961
name="col2",
962962
)
963963
tm.assert_series_equal(result, expected)
964+
965+
966+
def test_apply_function_with_indexing_return_column():
967+
# GH: 7002
968+
df = DataFrame({'foo1': ['one', 'two', 'two', 'three', 'one', 'two'],
969+
'foo2': np.random.randn(6)})
970+
result = df.groupby('foo1', as_index=False).apply(lambda x: x.mean())
971+
expected = df.groupby('foo1', as_index=False).mean()
972+
tm.assert_frame_equal(result, expected)
973+
assert 'foo1' in result.columns

0 commit comments

Comments
 (0)