12
两个数组:如何将numpy二维数组与numpy一维数组相乘?
a = numpy.array([[2,3,2],[5,6,1]])
b = numpy.array([3,5])
c = a * b
我要的是:
c = [[6,9,6],
[25,30,5]]
但是,我得到这个错误:
ValueError: operands could not be broadcast together with shapes (2,3) (2)
如何乘钕阵列1D数组,其中len(1D-array) == len(nD array)
?
谢谢!这个语法在Python中的名称是什么:'[:,None]'? – 2013-04-26 06:14:29
@Ashwin,你可以为它搜索'numpy.newaxis'。 – HYRY 2013-04-26 06:18:36
谢谢!接受你的回答:-) – 2013-04-26 07:05:26