-2
这是我想要的行为:cbind(R功能)相当于numpy的
import numpy as np
x = np.array([[1,2],[3,4]])
y = np.array([5, 6])
cbind(x,y) # desired result: np.array([[1,2,5],[3,4,6]])
好像应该很容易,但我的选项上http://mathesaurus.sourceforge.net/r-numpy.html(串联,hstack等)不工作发现如:
np.hstack((x,y))
给
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "X/site-packages/numpy/core/shape_base.py", line 288, in hstack
return _nx.concatenate(arrs, 1)
ValueError: all the input arrays must have same number of dimensions