@@ -1043,23 +1043,28 @@ def test_sum_bools(self):
10431043 bools = isna (df )
10441044 assert bools .sum (axis = 1 )[0 ] == 10
10451045
1046- def test_sum_string_dtype_coercion (self ):
1046+ @pytest .mark .parametrize (
1047+ "df, expected" ,
1048+ [
1049+ (
1050+ DataFrame ({"a" : ["483" , "3" ], "b" : ["94" , "759" ]}),
1051+ Series (["48394" , "3759" ]),
1052+ ),
1053+ (
1054+ DataFrame ({"a" : ["483.948" , "3.0" ], "b" : ["94.2" , "759.93" ]}),
1055+ Series (["483.94894.2" , "3.0759.93" ]),
1056+ ),
1057+ (
1058+ DataFrame ({"a" : ["483" , "3.0" ], "b" : ["94.2" , "79" ]}),
1059+ Series (["48394.2" , "3.079" ]),
1060+ ),
1061+ ],
1062+ )
1063+ def test_sum_string_dtype_coercion (self , df , expected ):
10471064 # GH#22642
10481065 # Check that summing numeric strings results in concatenation
10491066 # and not conversion to dtype int64 or float64
1050- df = DataFrame ({"a" : ["483" , "3" ], "b" : ["94" , "759" ]})
1051- result = df .sum (axis = 1 )
1052- expected = Series (["48394" , "3759" ])
1053- tm .assert_series_equal (result , expected )
1054-
1055- df = DataFrame ({"a" : ["483.948" , "3.0" ], "b" : ["94.2" , "759.93" ]})
1056- result = df .sum (axis = 1 )
1057- expected = Series (["483.94894.2" , "3.0759.93" ])
1058- tm .assert_series_equal (result , expected )
1059-
1060- df = DataFrame ({"a" : ["483" , "3.0" ], "b" : ["94.2" , "79" ]})
10611067 result = df .sum (axis = 1 )
1062- expected = Series (["48394.2" , "3.079" ])
10631068 tm .assert_series_equal (result , expected )
10641069
10651070 # ----------------------------------------------------------------------
0 commit comments