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

后端 未结 4 950
既然无缘
既然无缘 2020-12-24 03:28

I\'m having a problem with np.append.

I\'m trying to duplicate the last column of 20x361 matrix n_list_converted by using the code below:

4条回答
  •  情深已故
    2020-12-24 04:07

    (n,) and (n,1) are not the same shape. Try casting the vector to an array by using the [:, None] notation:

    n_lists = np.append(n_list_converted, n_last[:, None], axis=1)
    

    Alternatively, when extracting n_last you can use

    n_last = n_list_converted[:, -1:]
    

    to get a (20, 1) array.

提交回复
热议问题