@@ -79,7 +79,7 @@ def test_get_dummies_basic(self, sparse, dtype):
79
79
result = get_dummies (s_series_index , sparse = sparse , dtype = dtype )
80
80
tm .assert_frame_equal (result , expected )
81
81
82
- def test_get_dummies_basic_types (self , sparse , dtype ):
82
+ def test_get_dummies_basic_types (self , sparse , dtype , using_infer_string ):
83
83
# GH 10531
84
84
s_list = list ("abc" )
85
85
s_series = Series (s_list )
@@ -120,7 +120,8 @@ def test_get_dummies_basic_types(self, sparse, dtype):
120
120
121
121
result = get_dummies (s_df , columns = ["a" ], sparse = sparse , dtype = dtype )
122
122
123
- expected_counts = {"int64" : 1 , "object" : 1 }
123
+ key = "string" if using_infer_string else "object"
124
+ expected_counts = {"int64" : 1 , key : 1 }
124
125
expected_counts [dtype_name ] = 3 + expected_counts .get (dtype_name , 0 )
125
126
126
127
expected = Series (expected_counts , name = "count" ).sort_index ()
@@ -213,7 +214,7 @@ def test_dataframe_dummies_all_obj(self, df, sparse):
213
214
214
215
tm .assert_frame_equal (result , expected )
215
216
216
- def test_dataframe_dummies_string_dtype (self , df ):
217
+ def test_dataframe_dummies_string_dtype (self , df , using_infer_string ):
217
218
# GH44965
218
219
df = df [["A" , "B" ]]
219
220
df = df .astype ({"A" : "object" , "B" : "string" })
@@ -227,7 +228,9 @@ def test_dataframe_dummies_string_dtype(self, df):
227
228
},
228
229
dtype = bool ,
229
230
)
230
- expected [["B_b" , "B_c" ]] = expected [["B_b" , "B_c" ]].astype ("boolean" )
231
+ if not using_infer_string :
232
+ # infer_string returns numpy bools
233
+ expected [["B_b" , "B_c" ]] = expected [["B_b" , "B_c" ]].astype ("boolean" )
231
234
tm .assert_frame_equal (result , expected )
232
235
233
236
def test_dataframe_dummies_mix_default (self , df , sparse , dtype ):
0 commit comments