Numpy concatenate 2D arrays with 1D array

前端 未结 3 1827
轻奢々
轻奢々 2020-12-09 15:16

I am trying to concatenate 4 arrays, one 1D array of shape (78427,) and 3 2D array of shape (78427, 375/81/103). Basically this are 4 arrays with features for 78427 images,

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 15:55

    Try concatenating X_Yscores[:, None] (or X_Yscores[:, np.newaxis] as imaluengo suggests). This creates a 2D array out of a 1D array.

    Example:

    A = np.array([1, 2, 3])
    print A.shape
    print A[:, None].shape
    

    Output:

    (3,)
    (3,1)
    

提交回复
热议问题