From 53a206b4d3a1a63ed0721ceaedba43feb308645e Mon Sep 17 00:00:00 2001 From: Skipper Seabold Date: Tue, 11 Mar 2014 13:58:10 -0400 Subject: [PATCH 1/2] BUG: iloc back to values for assignment. Closes #6602. --- pandas/util/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index a0876179ee4af..a3d35401fd0c0 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -973,7 +973,7 @@ def makeMissingCustomDataframe(nrows, ncols, density=.9, random_state=None, r_idx_type=r_idx_type) i, j = _create_missing_idx(nrows, ncols, density, random_state) - df.iloc[i, j] = np.nan + df.values[i, j] = np.nan return df @@ -981,7 +981,7 @@ def makeMissingDataframe(density=.9, random_state=None): df = makeDataFrame() i, j = _create_missing_idx(*df.shape, density=density, random_state=random_state) - df.iloc[i, j] = np.nan + df.values[i, j] = np.nan return df From f3e43973b860a96f738ebd547b296740a951ca8d Mon Sep 17 00:00:00 2001 From: Skipper Seabold Date: Tue, 11 Mar 2014 14:00:40 -0400 Subject: [PATCH 2/2] ENH: Make sure to return int for indices --- pandas/util/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index a3d35401fd0c0..2860cdf3b200d 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -941,8 +941,8 @@ def _gen_unique_rand(rng, _extra_size): extra_size *= 1.05 ind = _gen_unique_rand(random_state, extra_size) - j = np.floor(ind * 1. / nrows) - i = (ind - j * nrows) + j = np.floor(ind * 1. / nrows).astype(int) + i = (ind - j * nrows).astype(int) return i.tolist(), j.tolist()