@@ -186,7 +186,7 @@ def test_astype_str_float(self):
186186 tm .assert_frame_equal (result , expected )
187187
188188 @pytest .mark .parametrize ("dtype_class" , [dict , Series ])
189- def test_astype_dict_like (self , dtype_class ):
189+ def test_astype_dict_like (self , dtype_class , using_infer_string ):
190190 # GH7271 & GH16717
191191 a = Series (date_range ("2010-01-04" , periods = 5 ))
192192 b = Series (range (5 ))
@@ -201,7 +201,10 @@ def test_astype_dict_like(self, dtype_class):
201201 expected = DataFrame (
202202 {
203203 "a" : a ,
204- "b" : Series (["0" , "1" , "2" , "3" , "4" ], dtype = "object" ),
204+ "b" : Series (
205+ ["0" , "1" , "2" , "3" , "4" ],
206+ dtype = "str" if using_infer_string else "object" ,
207+ ),
205208 "c" : c ,
206209 "d" : Series ([1.0 , 2.0 , 3.14 , 4.0 , 5.4 ], dtype = "float32" ),
207210 }
@@ -262,9 +265,9 @@ def test_astype_duplicate_col(self):
262265 a2 = Series ([0 , 1 , 2 , 3 , 4 ], name = "a" )
263266 df = concat ([a1 , b , a2 ], axis = 1 )
264267
265- result = df .astype (str )
268+ result = df .astype (" str" )
266269 a1_str = Series (["1" , "2" , "3" , "4" , "5" ], dtype = "str" , name = "a" )
267- b_str = Series (["0.1" , "0.2" , "0.4" , "0.6" , "0.8" ], dtype = str , name = "b" )
270+ b_str = Series (["0.1" , "0.2" , "0.4" , "0.6" , "0.8" ], dtype = " str" , name = "b" )
268271 a2_str = Series (["0" , "1" , "2" , "3" , "4" ], dtype = "str" , name = "a" )
269272 expected = concat ([a1_str , b_str , a2_str ], axis = 1 )
270273 tm .assert_frame_equal (result , expected )
0 commit comments