I have two numpy arrays, array_one which is NxM and array_two which is NxMx3, and I'd like to change the value of the last element in each row of array_two, based on values from array_one, like this:
array_two[i, j, -1] = foo(array_one[i,j])
where foo returns a value based on a computation on an element from array_one.
Is there a way to avoid manually looping over the arrays and speed up this process using numpy functions?
foocan be vectorized.foofunction. Does it support passing numpy array? for example,array_two[:,:,-1] = np.sum(array_one)would work, butarray_two[:,:,-1] = math.sin(array_one)wouldn't.