I have an array of zeros (17520,5) that I want to fill with two values: 0 and 0.05. I have two conditions, and I am using the function np.where, however, I only need to apply the second condition at specific indices of the array. The code I am using is as follows:
independent = np.zeros([17520,5])
w1 = np.where(independent == 0)
independent[w1] = np.random.choice([0.0, 0.05], size=len(w1[0]))
This part of the code works fine, and fills the zero array (independent) with the desired values: 0 and 0.05 with the same proportion (50/50). On the other hand, the second condition needs to be implemented only at specific indices, something as follows:
for n in range(0, 365):
start = 24 + n*48
end = 46 + n*48
w2 = np.where(independent == 0.05)
independent[w2][start:end,0:5]=np.random.choice([0.0, 0.05], (22,5),size=len(w2[0]))
Where [start:end,0:5] indicates the indices where I want to implement the conditions w2.
I would appreciate your help indicating the correct way to use the function np.where with indices, because at the moment I am having the following error
SyntaxError: invalid syntax