diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index a130983337f64..08adb580ff08f 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1697,7 +1697,7 @@ def maybe_cast_to_integer_array(arr: list | np.ndarray, dtype: np.dtype) -> np.n ) raise ValueError("Trying to coerce float values to integers") if arr.dtype == object: - raise ValueError("Trying to coerce float values to integers") + raise ValueError("Trying to coerce object values to integers") if casted.dtype < arr.dtype: # TODO: Can this path be hit anymore with numpy > 2 diff --git a/pandas/tests/indexes/numeric/test_numeric.py b/pandas/tests/indexes/numeric/test_numeric.py index 676d33d2b0f81..8dde5febe810d 100644 --- a/pandas/tests/indexes/numeric/test_numeric.py +++ b/pandas/tests/indexes/numeric/test_numeric.py @@ -397,7 +397,7 @@ def test_constructor_corner(self, dtype): # preventing casting arr = np.array([1, "2", 3, "4"], dtype=object) - msg = "Trying to coerce float values to integers" + msg = "Trying to coerce object values to integers" with pytest.raises(ValueError, match=msg): index_cls(arr, dtype=dtype)