这个问题在这里已经有答案:
How to conditionally combine two numpy arrays of the same shape(2个答案)
两年前就关闭了。
我试过这样做:
A = np.asmatrix(np.random.rand(4,1))
B = np.asmatrix(np.random.rand(4,1))
C = np.min(A, B)
让A和B如下所示:
A = [[0.13456968]
[0.80465702]
[0.08426155]
[0.85041178]]
B = [[0.64932459]
[0.77806739]
[0.15517366]
[0.10992883]]
我想要C,如下所示:
C = [[0.13456968]
[0.77806739]
[0.08426155]
[0.10992883]]
但这会产生以下错误:
TypeError: only integer scalar arrays can be converted to a scalar index
2条答案
按热度按时间2guxujil1#
您需要使用Minimum()而不是min():
tvz2xvvm2#
尝试将其替换为