File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 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():
26582658 s .groupby (level = 0 ).backfill ()
26592659 with tm .assert_produces_warning (FutureWarning , match = "pad" ):
26602660 s .groupby (level = 0 ).pad ()
2661+
2662+
2663+ def test_by_column_values_with_same_starting_value ():
2664+ # GH29635
2665+ df = DataFrame (
2666+ {
2667+ "Name" : ["Thomas" , "Thomas" , "Thomas John" ],
2668+ "Credit" : [1200 , 1300 , 900 ],
2669+ "Mood" : ["sad" , "happy" , "happy" ],
2670+ }
2671+ )
2672+ aggregate_details = {"Mood" : Series .mode , "Credit" : "sum" }
2673+
2674+ result = df .groupby (["Name" ]).agg (aggregate_details )
2675+ expected_result = 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