@@ -44,7 +44,6 @@ def test_from_dtype_from_float(data):
4444
4545
4646def test_conversions (data_missing ):
47-
4847 # astype to object series
4948 df = pd .DataFrame ({"A" : data_missing })
5049 result = df ["A" ].astype ("object" )
@@ -123,7 +122,6 @@ def test_to_integer_array_none_is_nan(a, b):
123122 "values" ,
124123 [
125124 ["foo" , "bar" ],
126- ["1" , "2" ],
127125 "foo" ,
128126 1 ,
129127 1.0 ,
@@ -137,13 +135,14 @@ def test_to_integer_array_error(values):
137135 # error in converting existing arrays to IntegerArrays
138136 msg = (
139137 r"(:?.* cannot be converted to an IntegerDtype)"
138+ r"|(invalid literal for int\(\) with base 10: .*)"
140139 r"|(:?values must be a 1D list-like)"
141140 r"|(Cannot pass scalar)"
142141 )
143142 with pytest .raises ((ValueError , TypeError ), match = msg ):
144143 pd .array (values , dtype = "Int64" )
145144
146- with pytest .raises (TypeError , match = msg ):
145+ with pytest .raises (( ValueError , TypeError ) , match = msg ):
147146 IntegerArray ._from_sequence (values )
148147
149148
@@ -181,6 +180,22 @@ def test_to_integer_array_float():
181180 assert result .dtype == Int64Dtype ()
182181
183182
183+ def test_to_integer_array_str ():
184+ result = IntegerArray ._from_sequence (["1" , "2" , None ])
185+ expected = pd .array ([1 , 2 , np .nan ], 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" , "2" , "" ])
192+
193+ with pytest .raises (
194+ ValueError , match = r"invalid literal for int\(\) with base 10: .*"
195+ ):
196+ IntegerArray ._from_sequence (["1.5" , "2.0" ])
197+
198+
184199@pytest .mark .parametrize (
185200 "bool_values, int_values, target_dtype, expected_dtype" ,
186201 [
0 commit comments