I am trying to use np.where to swap one element for another, in the same row (but different column).
Here is what I have so far:
arr = np.random.random_integers(0,10,size=(10,10))
split = np.random.random_integers(0,10,size=arr[1,:].shape)
newloc = np.random.random_integers(0,10,size=arr[1,:].shape)
arr2 = np.where(arr>split,arr[0,newloc],arr)
My problem is that 0 in arr[0,newloc] means that it always pulls from row 0 off arr. But I want something like "same_row" if that makes sense.
newlocis an array, what do intend to do here:arr[0,newloc]?arr[0,newloc[same_col_asarr]]I just don't know how to do it. My goal is basically if: arr>split, return a different element in the same row as arr, the location of which is held in newloc.