@@ -40,6 +40,7 @@ def test_get_dummies_index():
40
40
tm .assert_index_equal (result , expected )
41
41
42
42
43
+ # GH#47872
43
44
@pytest .mark .parametrize (
44
45
"dtype" ,
45
46
[
@@ -67,6 +68,7 @@ def test_get_dummies_with_dtype(any_string_dtype, dtype):
67
68
tm .assert_frame_equal (result , expected )
68
69
69
70
71
+ # GH#47872
70
72
@td .skip_if_no ("pyarrow" )
71
73
@pytest .mark .parametrize (
72
74
"dtype" ,
@@ -91,3 +93,31 @@ def test_get_dummies_with_pyarrow_dtype(any_string_dtype, dtype):
91
93
dtype = dtype ,
92
94
)
93
95
tm .assert_frame_equal (result , expected )
96
+
97
+
98
+ # GH#47872
99
+ def test_get_dummies_with_str_dtype (any_string_dtype ):
100
+ s = Series (["a|b" , "a|c" , np .nan ], dtype = any_string_dtype )
101
+ result = s .str .get_dummies ("|" , dtype = str )
102
+ expected = DataFrame (
103
+ [["T" , "T" , "F" ], ["T" , "F" , "T" ], ["F" , "F" , "F" ]],
104
+ columns = list ("abc" ),
105
+ dtype = str ,
106
+ )
107
+ tm .assert_frame_equal (result , expected )
108
+
109
+
110
+ # GH#47872
111
+ def test_get_dummies_with_pa_str_dtype (any_string_dtype ):
112
+ s = Series (["a|b" , "a|c" , np .nan ], dtype = any_string_dtype )
113
+ result = s .str .get_dummies ("|" , dtype = "str[pyarrow]" )
114
+ expected = DataFrame (
115
+ [
116
+ ["true" , "true" , "false" ],
117
+ ["true" , "false" , "true" ],
118
+ ["false" , "false" , "false" ],
119
+ ],
120
+ columns = list ("abc" ),
121
+ dtype = "str[pyarrow]" ,
122
+ )
123
+ tm .assert_frame_equal (result , expected )
0 commit comments