@@ -760,7 +760,7 @@ def test_constructor_dict_cast(self, using_infer_string):
760760
761761 frame = DataFrame (test_data )
762762 assert len (frame ) == 3
763- assert frame ["B" ].dtype == np .object_ if not using_infer_string else "string "
763+ assert frame ["B" ].dtype == np .object_ if not using_infer_string else "str "
764764 assert frame ["A" ].dtype == np .float64
765765
766766 def test_constructor_dict_cast2 (self ):
@@ -1182,7 +1182,7 @@ def test_constructor_scalar_inference(self, using_infer_string):
11821182 assert df ["bool" ].dtype == np .bool_
11831183 assert df ["float" ].dtype == np .float64
11841184 assert df ["complex" ].dtype == np .complex128
1185- assert df ["object" ].dtype == np .object_ if not using_infer_string else "string "
1185+ assert df ["object" ].dtype == np .object_ if not using_infer_string else "str "
11861186
11871187 def test_constructor_arrays_and_scalars (self ):
11881188 df = DataFrame ({"a" : np .random .default_rng (2 ).standard_normal (10 ), "b" : True })
@@ -1265,7 +1265,7 @@ def test_constructor_list_of_lists(self, using_infer_string):
12651265 # GH #484
12661266 df = DataFrame (data = [[1 , "a" ], [2 , "b" ]], columns = ["num" , "str" ])
12671267 assert is_integer_dtype (df ["num" ])
1268- assert df ["str" ].dtype == np .object_ if not using_infer_string else "string "
1268+ assert df ["str" ].dtype == np .object_ if not using_infer_string else "str "
12691269
12701270 # GH 4851
12711271 # list of 0-dim ndarrays
@@ -1833,7 +1833,12 @@ def test_constructor_with_datetimes(self, using_infer_string):
18331833 result = df .dtypes
18341834 expected = Series (
18351835 [np .dtype ("int64" )]
1836- + [np .dtype (objectname ) if not using_infer_string else "string" ] * 2
1836+ + [
1837+ np .dtype (objectname )
1838+ if not using_infer_string
1839+ else pd .StringDtype (na_value = np .nan )
1840+ ]
1841+ * 2
18371842 + [np .dtype ("M8[s]" ), np .dtype ("M8[us]" )],
18381843 index = list ("ABCDE" ),
18391844 )
@@ -1855,7 +1860,11 @@ def test_constructor_with_datetimes(self, using_infer_string):
18551860 expected = Series (
18561861 [np .dtype ("float64" )]
18571862 + [np .dtype ("int64" )]
1858- + [np .dtype ("object" ) if not using_infer_string else "string" ]
1863+ + [
1864+ np .dtype ("object" )
1865+ if not using_infer_string
1866+ else pd .StringDtype (na_value = np .nan )
1867+ ]
18591868 + [np .dtype ("float64" )]
18601869 + [np .dtype (intname )],
18611870 index = ["a" , "b" , "c" , floatname , intname ],
@@ -1877,7 +1886,11 @@ def test_constructor_with_datetimes(self, using_infer_string):
18771886 expected = Series (
18781887 [np .dtype ("float64" )]
18791888 + [np .dtype ("int64" )]
1880- + [np .dtype ("object" ) if not using_infer_string else "string" ]
1889+ + [
1890+ np .dtype ("object" )
1891+ if not using_infer_string
1892+ else pd .StringDtype (na_value = np .nan )
1893+ ]
18811894 + [np .dtype ("float64" )]
18821895 + [np .dtype (intname )],
18831896 index = ["a" , "b" , "c" , floatname , intname ],
@@ -2103,7 +2116,9 @@ def test_constructor_for_list_with_dtypes(self, using_infer_string):
21032116 [
21042117 np .dtype ("int64" ),
21052118 np .dtype ("float64" ),
2106- np .dtype ("object" ) if not using_infer_string else "string" ,
2119+ np .dtype ("object" )
2120+ if not using_infer_string
2121+ else pd .StringDtype (na_value = np .nan ),
21072122 np .dtype ("datetime64[us]" ),
21082123 np .dtype ("float64" ),
21092124 ],
0 commit comments