Skip to content

Commit e3a49fe

Browse files
committed
TST: groupby apply with indexing and column aggregation returns the column (pandas-dev#7002)
1 parent 99fee1f commit e3a49fe

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/groupby/test_apply.py

+10
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)