Np.concatenate ValueError: all the input arrays must have same number of dimensions
<p>I am trying to concatenate but ended up with the mentioned error. Am also new to python. </p>

<pre><code>def cving(x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, ind1, ind2, ind3, ind4, ind5, num):

if num == 0:
    xwhole = np.concatenate((x2, x3, x4, x5), axis=0)
    yhol = np.concatenate((y2, y3, y4, y5), axis=0)
    return x1, y1, ind1, xwhole, yhol
elif num == 1:
    xwhole = np.concatenate((x1, x3, x4, x5), axis=0)
    yhol = np.concatenate((y1, y3, y4, y5), axis=0)
    return x2, y2, ind2, xwhole, yhol
elif num == 2:
    xwhole = np.concatenate((x1, x2, x4, x5), axis=0)
    yhol = np.concatenate((y1, y2, y4, y5), axis=0)
    return x3, y3, ind3, xwhole, yhol
elif num == 3:
    xwhole = np.concatenate((x1, x2, x3, x5), axis=0)
    yhol = np.concatenate((y1, y2, y3, y5), axis=0)
    return x4, y4, ind4, xwhole, yhol
else:
    xwhole = np.concatenate((x1, x2, x3, x4), axis=0)
    yhol = np.concatenate((y1, y2, y3, y4), axis=0)
    return x5, y5, ind5, xwhole, yhol
</code></pre>

<p>Here are some of the output of x1,x2,x3 and x4 *To show some of the output which is used for np.concantate</p>

<pre><code>x1 = [[  1.21537030e+07   5.73132800e+06   1.39127063e-01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]
[  2.19181650e+07   6.31495600e+06   1.58992826e-01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]
[  9.35311000e+05   5.93920000e+05   1.40974499e-01 ...,   0.00000000e+00
0.00000000e+00   0.00000000e+00]]

x2= []

x3= []

x4 = [  1.11088300e+06   1.23238400e+06   1.32048109e-01   1.05878525e-01
9.01409788e-01   1.24716612e+00   7.22766415e-01   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   0.00000000e+00   1.15544472e-01   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
1.54537898e-02   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   7.82815688e-01
1.13352981e-04   1.13352981e-04   0.00000000e+00   0.00000000e+00
8.52792262e-02   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
0.00000000e+00   6.80117887e-04   0.00000000e+00   0.00000000e+00]
</code></pre>

<p>The error message says it all: <code>x1</code> is 2D while <code>x4</code> is 1D. Concatenating these makes no sense. You need to make sure all concatenated arrays are of same dimension, e.g. by adding a dimension to all 1D arrays</p>

<pre><code>x4 = x4[:, np.newaxis]
</code></pre>

python np