Skip to content

Commit ec34173

Browse files
discortvictor
authored and
victor
committed
TEST: added test for agg with list-like func (pandas-dev#22467)
1 parent 143f657 commit ec34173

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/groupby/aggregate/test_other.py

+11
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,14 @@ def test_agg_category_nansum(observed):
512512
if observed:
513513
expected = expected[expected != 0]
514514
tm.assert_series_equal(result, expected)
515+
516+
517+
def test_agg_list_like_func():
518+
# GH 18473
519+
df = pd.DataFrame({'A': [str(x) for x in range(3)],
520+
'B': [str(x) for x in range(3)]})
521+
grouped = df.groupby('A', as_index=False, sort=False)
522+
result = grouped.agg({'B': lambda x: list(x)})
523+
expected = pd.DataFrame({'A': [str(x) for x in range(3)],
524+
'B': [[str(x)] for x in range(3)]})
525+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)