• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
116 views

Problem:

I am trying to concatenate numpy arrays but i am ending up with following out come:

In [2]: np.append(arrayX, arrayY, axis=0)

Out[2]: array([[ 0.,  1.,  2.,  3.],

       [ 4.,  5.,  6.,  7.],

       [ 8.,  9., 10., 11.],

       [ 1.,  1.,  1.,  1.]])

In [2]: np.append(arrayX, np.ones((1, 3)), axis=0)

        ---------------------------------------------------------------------------

        ValueError                                Traceback (most recent call last)

        <ipython-input-25-fe0fb14f5df8> in <module>()

        ----> 1 np.append(arrayX, np.ones((1, 3)), axis=0)

        D:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\function_base.py in append(arr, values, axis)

           5164         values = ravel(values)

           5165         axis = arr.ndim-1

        -> 5166     return concatenate((arr, values), axis=axis)

        ValueError: all the input array dimensions except for the concatenation axis must match exactly

valueerror: all the input array dimensions except for the concatenation axis must match exactly

by (5.3k points)  
edited by

1 Answer

0 votes

Solution:

The array values is appended to array in the direction of column when axis value is 0.

the error is raised ie ll the input array dimensions except for the concatenation axis must match exactly, if 

2 arrays does not have equal length in row.

The best way to tackle this issue is to user row direction with parameter axis=1

Some links worth reading:

https://github.com/SheffieldML/GPyOpt/issues/185

by (1.4k points)  
...