def check_limits(bad_array, maxs):
    good_array = np.copy(bad_array)
for i_column in range(bad_array.shape[1]):
    to_replace = good_array[:, (i_column)] >= maxs[i_column]
good_array[to_replace, i_column] = maxs[i_column] - 1
return good_array
Replacing values greater than a limit in a numpy array