将列添加到二维列表

Rag*_* MG 2 python numpy concatenation python-3.x

我有一个二维数组列表,例如

  array( [ 988,  389],
         [ 986,  389],
         [ 985,  388],
         [ 977,  388],
         [ 976,  387]], dtype=int32)
Run Code Online (Sandbox Code Playgroud)

和另一个列表

 array( [ 149.68299837],
        [ 149.25481567],
        [ 150.029997  ],
        [ 148.63714206],
        [ 149.48244044]])
Run Code Online (Sandbox Code Playgroud)

我尝试使用连接这两个列表

  trail = list(map(list,zip(two_d_array,concat)))
  trail = np.vstack(trail)
Run Code Online (Sandbox Code Playgroud)

这给了我

  array([array([988, 389], dtype=int32), array([ 149.68299837])],
        [array([986, 389], dtype=int32), array([ 149.25481567])],
        [array([985, 388], dtype=int32), array([ 150.029997])],
        [array([977, 388], dtype=int32), array([ 148.63714206])],
        [array([976, 387], dtype=int32), array([ 149.48244044])]], dtype=object)
Run Code Online (Sandbox Code Playgroud)

如何删除所有数组和数据类型并仅显示数字,例如

     [ 988,  389,149.68299837],
     [ 986,  389,149.25481567],
     [ 985,  388, 150.029997],
     [ 977,  388,148.63714206],
     [ 976,  387,149.48244044]
Run Code Online (Sandbox Code Playgroud)

NaN*_*NaN 5

我喜欢 np.c_ 和 np.column_stack (@Divakar 建议),因为我不太关心时间,但我更感兴趣的是它在视觉上“看起来”如何以便理解的目的......

>>> a = np.arange(10).reshape(5, 2)
>>> b = np.arange(10,15)
>>> c = np.c_[a,b]
>>> a
array([[0, 1],
       [2, 3],
       [4, 5],
       [6, 7],
       [8, 9]])
>>> b
array([10, 11, 12, 13, 14])
>>> c
array([[ 0,  1, 10],
       [ 2,  3, 11],
       [ 4,  5, 12],
       [ 6,  7, 13],
       [ 8,  9, 14]])
>>> np.column_stack((a,b))
array([[ 0,  1, 10],
       [ 2,  3, 11],
       [ 4,  5, 12],
       [ 6,  7, 13],
       [ 8,  9, 14]])
Run Code Online (Sandbox Code Playgroud)

数组a和b是显而易见的。我只需要记住做 np.c_ 方括号(np.c_[堆叠这些],当然,按列堆叠对我来说也有意义。