Suppose I have a numpy array:
[[2, 1, 1, 1],
[0, 2, 1, 1],
[0, 0, 2, 1]]
How do I change all of the twos to be ones?
[[1, 1, 1, 1],
[0, 1, 1, 1],
[0, 0, 1, 1]]
There are naive ways to do it that are really slow (i.e. looping through every entry). I have to do it on a large dataset, so a fast solution is essential.