diff --git a/pandas/core/arrays/integer.py b/pandas/core/arrays/integer.py index 52762514d00c2..17e92c3976e2c 100644 --- a/pandas/core/arrays/integer.py +++ b/pandas/core/arrays/integer.py @@ -173,8 +173,11 @@ def coerce_to_array(values, dtype, mask=None, copy=False): values = np.array(values, copy=copy) if is_object_dtype(values): inferred_type = lib.infer_dtype(values) - if inferred_type not in ['floating', 'integer', - 'mixed-integer', 'mixed-integer-float']: + if inferred_type is 'mixed' and isna(values).any(): + values = np.empty(len(values)) + values.fill(np.nan) + elif inferred_type not in ['floating', 'integer', + 'mixed-integer', 'mixed-integer-float']: raise TypeError("{} cannot be converted to an IntegerDtype".format( values.dtype)) diff --git a/pandas/tests/arrays/test_integer.py b/pandas/tests/arrays/test_integer.py index 66d2baac8c91c..e6dae0ffaec28 100644 --- a/pandas/tests/arrays/test_integer.py +++ b/pandas/tests/arrays/test_integer.py @@ -527,9 +527,9 @@ def test_integer_array_constructor(): @pytest.mark.parametrize('a, b', [ ([1, None], [1, np.nan]), - pytest.param([None], [np.nan], - marks=pytest.mark.xfail(reason='GH-23224', - strict=True)), + ([None], [np.nan]), + ([None, np.nan], [np.nan, np.nan]), + ([np.nan, np.nan], [np.nan, np.nan]), ]) def test_integer_array_constructor_none_is_nan(a, b): result = integer_array(a) @@ -559,7 +559,8 @@ def test_integer_array_constructor_copy(): 1, 1.0, pd.date_range('20130101', periods=2), - np.array(['foo'])]) + np.array(['foo']), + [[1, 2], [3, 4]]]) def test_to_integer_array_error(values): # error in converting existing arrays to IntegerArrays with pytest.raises(TypeError):