data = numpy.array([[1, 2, 3], [55, 56, 57], [1, 2, 3]])
to_select = numpy.array([1, 2, 3] * 3).reshape(3, 3)
selected_indices = data == to_select
data = numpy.where(selected_indices, [4, 5, 6], data)
data = numpy.where(data == numpy.array([1, 2, 3] * 3).reshape(3, 3), [4, 5,
    6], data)
Replace subarrays in numpy