File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2658,3 +2658,26 @@ def test_pad_backfill_deprecation():
2658
2658
s .groupby (level = 0 ).backfill ()
2659
2659
with tm .assert_produces_warning (FutureWarning , match = "pad" ):
2660
2660
s .groupby (level = 0 ).pad ()
2661
+
2662
+
2663
+ def test_by_column_values_with_same_starting_value ():
2664
+ # GH29635
2665
+ df = pd .DataFrame (
2666
+ {
2667
+ "Name" : ["Thomas" , "Thomas" , "Thomas John" ],
2668
+ "Credit" : [1200 , 1300 , 900 ],
2669
+ "Mood" : ["sad" , "happy" , "happy" ],
2670
+ }
2671
+ )
2672
+ aggregate_details = {"Mood" : pd .Series .mode , "Credit" : "sum" }
2673
+
2674
+ result = df .groupby (["Name" ]).agg (aggregate_details )
2675
+ expected_result = pd .DataFrame (
2676
+ {
2677
+ "Mood" : [["happy" , "sad" ], "happy" ],
2678
+ "Credit" : [2500 , 900 ],
2679
+ "Name" : ["Thomas" , "Thomas John" ],
2680
+ }
2681
+ ).set_index ("Name" )
2682
+
2683
+ tm .assert_frame_equal (result , expected_result )
You can’t perform that action at this time.
0 commit comments