Apologies is the title is not correct. I didn't know how to describe exactly what I am looking for. So coming from Matlab I want to be able to do the following in Python in one line if possible
Say I have an index array:
index_array= np.array([0,1,1,0,0,0,1])
and a data array:
data_array = np.zeros([len(index_array),2])
I want to place a value (e.g. 100) where index_array=0 to the data_array[:,0] and where index_array=1 to data_array[:,1]
I matlab you could do it with one line. Something like
data_array(index_array)=100
The best I could figure out in python is this
data_array [index_array==0,0]=100
data_array [index_array==1,1]=100
Is it possible to do it more efficiently (w.r.t. lines of code). Also it would be nice to scale for additional dimensions in data_array (beyond 2d)