In Numpy, I can concatenate two arrays end-to-end with np.append or np.concatenate:
>>> X = np.array([[1,2,3]])
>>> Y = np.array([[-1,-2,-3],[4,5,6]])
>>> Z = np.append(X, Y, axis=0)
>>> Z
array([[ 1, 2, 3],
[-1, -2, -3],
[ 4, 5, 6]])
But these make copies of their input arrays:
>>> Z[0,:] = 0
>>> Z
array([[ 0, 0, 0],
[-1, -2, -3],
[ 4, 5, 6]])
>>> X
array([[1, 2, 3]])
Is there a way to concatenate two arrays into a view, i.e. without copying? Would that require an np.ndarray subclass?

所有评论(0)