@@ -44,7 +44,6 @@ def test_from_dtype_from_float(data):
44
44
45
45
46
46
def test_conversions (data_missing ):
47
-
48
47
# astype to object series
49
48
df = pd .DataFrame ({"A" : data_missing })
50
49
result = df ["A" ].astype ("object" )
@@ -123,7 +122,6 @@ def test_to_integer_array_none_is_nan(a, b):
123
122
"values" ,
124
123
[
125
124
["foo" , "bar" ],
126
- ["1" , "2" ],
127
125
"foo" ,
128
126
1 ,
129
127
1.0 ,
@@ -137,13 +135,14 @@ def test_to_integer_array_error(values):
137
135
# error in converting existing arrays to IntegerArrays
138
136
msg = (
139
137
r"(:?.* cannot be converted to an IntegerDtype)"
138
+ r"|(invalid literal for int\(\) with base 10: .*)"
140
139
r"|(:?values must be a 1D list-like)"
141
140
r"|(Cannot pass scalar)"
142
141
)
143
142
with pytest .raises ((ValueError , TypeError ), match = msg ):
144
143
pd .array (values , dtype = "Int64" )
145
144
146
- with pytest .raises (TypeError , match = msg ):
145
+ with pytest .raises (( ValueError , TypeError ) , match = msg ):
147
146
IntegerArray ._from_sequence (values )
148
147
149
148
@@ -181,6 +180,17 @@ def test_to_integer_array_float():
181
180
assert result .dtype == Int64Dtype ()
182
181
183
182
183
+ def test_to_integer_array_str ():
184
+ result = IntegerArray ._from_sequence (["1" , "2" ])
185
+ expected = pd .array ([1 , 2 ], dtype = "Int64" )
186
+ tm .assert_extension_array_equal (result , expected )
187
+
188
+ with pytest .raises (
189
+ ValueError , match = r"invalid literal for int\(\) with base 10: .*"
190
+ ):
191
+ IntegerArray ._from_sequence (["1.5" , "2.0" ])
192
+
193
+
184
194
@pytest .mark .parametrize (
185
195
"bool_values, int_values, target_dtype, expected_dtype" ,
186
196
[
0 commit comments