diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 21e04bc1badf3..5809acbd55380 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1841,8 +1841,10 @@ def maybe_cast_to_integer_array( f"casted to the dtype {dtype}" ) from err - if np.array_equal(arr, casted): - return casted + with warnings.catch_warnings(): + warnings.filterwarnings("ignore") + if np.array_equal(arr, casted): + return casted # We do this casting to allow for proper # data and dtype checking. diff --git a/pandas/tests/frame/methods/test_combine_first.py b/pandas/tests/frame/methods/test_combine_first.py index 90df28ce74454..30aef0bc0ec98 100644 --- a/pandas/tests/frame/methods/test_combine_first.py +++ b/pandas/tests/frame/methods/test_combine_first.py @@ -400,7 +400,11 @@ def test_combine_first_string_dtype_only_na(self, nullable_string_dtype): pa_version_under7p0 and nullable_string_dtype == "string[pyarrow]", ): df2.set_index(["a", "b"], inplace=True) - result = df.combine_first(df2) + with tm.maybe_produces_warning( + PerformanceWarning, + pa_version_under7p0 and nullable_string_dtype == "string[pyarrow]", + ): + result = df.combine_first(df2) with tm.maybe_produces_warning( PerformanceWarning, pa_version_under7p0 and nullable_string_dtype == "string[pyarrow]",