Skip to content
Advertisement

Appending 1D Ndarray to 2D Ndarray

I’m attempting to append a 1D array which have generated by appending elements one at a time to a 2D array as a new row in the array.

JavaScript

I’m pretty lost as to why this code doesn’t work? They are both arrays of 5 elements, but get the following error? “ValueError: all the input arrays must have same number of dimensions”

Advertisement

Answer

a and b have different dim a is (2,5) and b is (5,) reshape b to be (1,5).

Then you can append b row-wise as following:

JavaScript
Advertisement