@@ -292,7 +292,7 @@ def test_regex_replace_dict_nested_gh4115(self):
292292 df = DataFrame (
293293 {"Type" : Series (["Q" , "T" , "Q" , "Q" , "T" ], dtype = object ), "tmp" : 2 }
294294 )
295- expected = DataFrame ({"Type" : Series ( [0 , 1 , 0 , 0 , 1 ], dtype = object ) , "tmp" : 2 })
295+ expected = DataFrame ({"Type" : [0 , 1 , 0 , 0 , 1 ], "tmp" : 2 })
296296 msg = "Downcasting behavior in `replace`"
297297 with tm .assert_produces_warning (FutureWarning , match = msg ):
298298 result = df .replace ({"Type" : {"Q" : 0 , "T" : 1 }})
@@ -304,7 +304,7 @@ def test_regex_replace_list_to_scalar(self, mix_abc):
304304 expec = DataFrame (
305305 {
306306 "a" : mix_abc ["a" ],
307- "b" : Series ( [np .nan ] * 4 , dtype = "str" ) ,
307+ "b" : [np .nan ] * 4 ,
308308 "c" : [np .nan , np .nan , np .nan , "d" ],
309309 }
310310 )
@@ -1633,14 +1633,6 @@ def test_replace_regex_dtype_frame(self, regex):
16331633 expected_df2 = DataFrame ({"A" : [1 ], "B" : ["1" ]})
16341634 with tm .assert_produces_warning (FutureWarning , match = msg ):
16351635 result_df2 = df2 .replace (to_replace = "0" , value = 1 , regex = regex )
1636-
1637- if regex :
1638- # TODO(infer_string): both string columns get cast to object,
1639- # while only needed for column A
1640- expected_df2 = DataFrame ({"A" : [1 ], "B" : ["1" ]}, dtype = object )
1641- else :
1642- expected_df2 = DataFrame ({"A" : Series ([1 ], dtype = object ), "B" : ["1" ]})
1643- result_df2 = df2 .replace (to_replace = "0" , value = 1 , regex = regex )
16441636 tm .assert_frame_equal (result_df2 , expected_df2 )
16451637
16461638 def test_replace_with_value_also_being_replaced (self ):
0 commit comments