@@ -908,6 +908,31 @@ def test_demo(self):
908
908
index = ['max' , 'min' , 'sum' ])
909
909
tm .assert_frame_equal (result .reindex_like (expected ), expected )
910
910
911
+ def test_agg_multiple_mixed_no_warning (self ):
912
+ # https://github.com/pandas-dev/pandas/issues/20909
913
+ mdf = pd .DataFrame ({'A' : [1 , 2 , 3 ],
914
+ 'B' : [1. , 2. , 3. ],
915
+ 'C' : ['foo' , 'bar' , 'baz' ],
916
+ 'D' : pd .date_range ('20130101' , periods = 3 )})
917
+ expected = pd .DataFrame ({"A" : [1 , 6 ], 'B' : [1.0 , 6.0 ],
918
+ "C" : ['bar' , 'foobarbaz' ],
919
+ "D" : [pd .Timestamp ('2013-01-01' ), pd .NaT ]},
920
+ index = ['min' , 'sum' ])
921
+ # sorted index
922
+ with tm .assert_produces_warning (None ):
923
+ result = mdf .agg (['min' , 'sum' ])
924
+
925
+ tm .assert_frame_equal (result , expected )
926
+
927
+ with tm .assert_produces_warning (None ):
928
+ result = mdf [['D' , 'C' , 'B' , 'A' ]].agg (['sum' , 'min' ])
929
+
930
+ # For backwards compatibility, the result's index is
931
+ # still sorted by function name, so it's ['min', 'sum']
932
+ # not ['sum', 'min'].
933
+ expected = expected [['D' , 'C' , 'B' , 'A' ]]
934
+ tm .assert_frame_equal (result , expected )
935
+
911
936
def test_agg_dict_nested_renaming_depr (self ):
912
937
913
938
df = pd .DataFrame ({'A' : range (5 ), 'B' : 5 })
0 commit comments