I am missing something simple here. I cannot figure out how to pass multiple columns of a 2D array (matrix) and output them as a single column array.
Here is a simple example:
import numpy as np
Z = lambda x1,x2: (x1*x2 - 3)^2 + 1
# a sample 2D array with 15 rows and 2 columns
x= np.arange(30).reshape((15,2))
answer = [Z(i[0],i[1]) for i in x]
The last line of code is where my problem lies. I would like the output to be a single column array with 15 rows.
As a final note: My code only uses 2 columns as inputs. If it could be further expanded to a flexible number of columns, it would be greatly appreciated.