I have a numpy array like this:
data = np.array([
[1,2,3],
[1,2,3],
[1,2,101],
[4,5,111],
[4,5,6],
[4,5,6],
[4,5,101],
[4,5,112],
[4,5,6],
])
In the third column, I want the value to be replaced with 10001 if the next one along is 101. which would result in an array like this:
data = np.array([
[1,2,3],
[1,2,10001],
[1,2,101],
[4,5,111],
[4,5,6],
[4,5,10001],
[4,5,101],
[4,5,112],
[4,5,6],
])
I tried this which I was certain would work but it doesn't...
dith = np.nditer(data[:, 2], op_flags=['readwrite'])
for i in dith:
if i+1 == 3:
i[...] = 10001
If anyone could help with this then that would be great.