diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py index 998ac9c8395ce..bdd54b5cf9ede 100644 --- a/pandas/tests/frame/indexing/test_setitem.py +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -61,7 +61,7 @@ class mystring(str): "dtype", ["int32", "int64", "uint32", "uint64", "float32", "float64"] ) def test_setitem_dtype(self, dtype, float_frame): - arr = np.random.randn(len(float_frame)) + arr = np.random.randint(1, 10, len(float_frame)) float_frame[dtype] = np.array(arr, dtype=dtype) assert float_frame[dtype].dtype.name == dtype diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index 146ba2c42e0be..ecc5d3060c0a2 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -217,7 +217,12 @@ def test_nlargest_boolean(self, data, expected): def test_nlargest_nullable(self, any_numeric_ea_dtype): # GH#42816 dtype = any_numeric_ea_dtype - arr = np.random.randn(10).astype(dtype.lower(), copy=False) + if dtype.startswith("UInt"): + # Can't cast from negative float to uint on some platforms + arr = np.random.randint(1, 10, 10) + else: + arr = np.random.randn(10) + arr = arr.astype(dtype.lower(), copy=False) ser = Series(arr.copy(), dtype=dtype) ser[1] = pd.NA