Im calculating results for each rows in 2D-array.
import numpy as np
xyz = np.array([[1, 2, 100],[2, 5, 100]])
resultcolumn1 = (xyz[:,0]+xyz[:,1])*xyz[:,2]
>>array([300, 700])
>>type 'numpy.ndarray'>
But when I'm trying to add this resultvector to rest of the 2D-array as a column
print np.concatenate((xyz, resultcolumn1.T), axis=1)
I get this error:
ValueError: all the input arrays must have same number of dimensions.
Declaring the same vector with double brackets. Works:
resultcolumn2=np.array([[300, 700]])
>>>array([[300, 700]])
>>><type 'numpy.ndarray'>
np.concatenate((xyz, resultcolumn2.T), axis=1)
>>>[[ 1 2 100 300]
[ 2 5 100 700]]
How do I change resultcolumn1 to match resultcolumn2? Also could this process be done in better fashion?