File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
pandas/tests/groupby/aggregate Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -512,3 +512,20 @@ def test_agg_category_nansum(observed):
512
512
if observed :
513
513
expected = expected [expected != 0 ]
514
514
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 (10 )],
520
+ 'B' : [str (x ) for x in range (10 )]})
521
+ result = df .groupby ('A' , as_index = False , sort = False )\
522
+ .aggregate ({'B' : lambda x : list (x )})
523
+ expected = df .copy ()
524
+ expected ['B' ] = df ['B' ].apply (lambda x : list (x ))
525
+ tm .assert_frame_equal (result , expected )
526
+
527
+ # Testing normal func
528
+ result = df .groupby ('A' , as_index = False , sort = False )\
529
+ .aggregate ({'B' : lambda x : x })
530
+ expected = df .copy ()
531
+ tm .assert_frame_equal (result , expected )
You can’t perform that action at this time.
0 commit comments