data = np.random.normal(0, 1, (10, 100))
for row in data:
    good_ones = np.logical_and(row >= -0.8, row <= 0.8)
good = row[good_ones]
row_copy = np.array([(x if f else random.choice(good)) for f, x in zip(
    good_ones, row)])
Efficient Array replacement in Python