ValueError: all the input arrays must have same number of dimensions . Stacking vectors

前端 未结 2 1875
慢半拍i
慢半拍i 2021-01-26 06:52

l have three arrays to append. Here a sample of my vectors :

V1=array([ 0.03317591, -0.01624349, -0.01151019])
V2=array([[ 0.06865846, -0.00223798],
       [-0.         


        
2条回答
  •  星月不相逢
    2021-01-26 07:13

    To use np.hstack, we need to convert V1 to 2D such that the lengths along the first axis for the three input arrays are the same -

    np.hstack((V1[:,None],V2,V3))
    

    As alternatives, we can use np.column_stack or np.concatenate along the second axis on 2D converted V1 alongwith others or np.c_ -

    np.column_stack((V1,V2,V3))
    np.concatenate([V1[:,None],V2,V3],axis=1)
    np.c_[V1,V2,V3]
    

提交回复
热议问题