Python how to convert a value with shape (1000L, 1L) to the value of the shape (1000L,)
<p>I has a variable with a shape of (1000L, 1L), but the structure causes some errors for subsequent analysis. It needs to be converted to the one with the shape (1000L,). Let me be more specific. </p>

<pre><code>import numpy as np
a = np.array([1,2,3])
b = np.array([[1],[2],[3]])
</code></pre>

<p>I want to convert b to a. Is there any quick way to do that?</p>

<p>There are a lot of ways you could do that, such as indexing:</p>

<pre><code>a = b[:, 0]
</code></pre>

<p>raveling:</p>

<pre><code>a = numpy.ravel(b)
</code></pre>

<p>or reshaping:</p>

<pre><code>a = numpy.reshape(b, (-1,))
</code></pre>

python numpy