I have a wide, binary, 2-d numpy array as follows:
np_var:
0, 0, 1, 0, 1, ..., 0, 1
1, 0, 1, 0, 0, ..., 1, 0
...
Each row has 8 non-zero elements. I would like to quickly replace the nth non-zero element in each row with a zero (to end up with 7 non-zero elements per row).
Is there a numpy way to perform this replacement quickly without a loop?