@@ -356,12 +356,17 @@ def test_apply_reduce_Series(self, float_frame):
356
356
result = float_frame .apply (np .mean , axis = 1 )
357
357
tm .assert_series_equal (result , expected )
358
358
359
- def test_apply_reduce_rows_to_dict (self ):
360
- # GH 25196
361
- data = DataFrame ([[1 , 2 ], [3 , 4 ]])
362
- expected = Series ([{0 : 1 , 1 : 3 }, {0 : 2 , 1 : 4 }])
363
- result = data .apply (dict )
364
- tm .assert_series_equal (result , expected )
359
+ def test_apply_reduce_to_dict (self ):
360
+ # GH 25196 37544
361
+ data = DataFrame ([[1 , 2 ], [3 , 4 ]], columns = ["c0" , "c1" ], index = ["i0" , "i1" ])
362
+
363
+ result0 = data .apply (dict , axis = 0 )
364
+ expected0 = Series ([{"i0" : 1 , "i1" : 3 }, {"i0" : 2 , "i1" : 4 }], index = data .columns )
365
+ tm .assert_series_equal (result0 , expected0 )
366
+
367
+ result1 = data .apply (dict , axis = 1 )
368
+ expected1 = Series ([{"c0" : 1 , "c1" : 2 }, {"c0" : 3 , "c1" : 4 }], index = data .index )
369
+ tm .assert_series_equal (result1 , expected1 )
365
370
366
371
def test_apply_differently_indexed (self ):
367
372
df = DataFrame (np .random .randn (20 , 10 ))
0 commit comments