@@ -292,7 +292,7 @@ def test_regex_replace_dict_nested_gh4115(self):
292
292
df = DataFrame (
293
293
{"Type" : Series (["Q" , "T" , "Q" , "Q" , "T" ], dtype = object ), "tmp" : 2 }
294
294
)
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 })
296
296
msg = "Downcasting behavior in `replace`"
297
297
with tm .assert_produces_warning (FutureWarning , match = msg ):
298
298
result = df .replace ({"Type" : {"Q" : 0 , "T" : 1 }})
@@ -304,7 +304,7 @@ def test_regex_replace_list_to_scalar(self, mix_abc):
304
304
expec = DataFrame (
305
305
{
306
306
"a" : mix_abc ["a" ],
307
- "b" : Series ( [np .nan ] * 4 , dtype = "str" ) ,
307
+ "b" : [np .nan ] * 4 ,
308
308
"c" : [np .nan , np .nan , np .nan , "d" ],
309
309
}
310
310
)
@@ -1633,14 +1633,6 @@ def test_replace_regex_dtype_frame(self, regex):
1633
1633
expected_df2 = DataFrame ({"A" : [1 ], "B" : ["1" ]})
1634
1634
with tm .assert_produces_warning (FutureWarning , match = msg ):
1635
1635
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 )
1644
1636
tm .assert_frame_equal (result_df2 , expected_df2 )
1645
1637
1646
1638
def test_replace_with_value_also_being_replaced (self ):
0 commit comments