Form a big 2d array from multiple smaller 2d arrays

前端 未结 5 662
囚心锁ツ
囚心锁ツ 2020-12-01 02:44

The question is the inverse of this question. I\'m looking for a generic method to from the original big array from small arrays:

array([[[ 0,  1,  2],
             


        
5条回答
  •  时光取名叫无心
    2020-12-01 02:44

    I hope I get you right, let's say we have a,b :

    >>> a = np.array([[1,2] ,[3,4]])
    >>> b = np.array([[5,6] ,[7,8]])
        >>> a
        array([[1, 2],
               [3, 4]])
        >>> b
        array([[5, 6],
               [7, 8]])
    

    in order to make it one big 2d array use numpy.concatenate:

    >>> c = np.concatenate((a,b), axis=1 )
    >>> c
    array([[1, 2, 5, 6],
           [3, 4, 7, 8]])
    

提交回复
热议问题