Python how to convert a value with shape (1000L, 1L) to the value of the shape (1000L,)
Question: 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.

    
    
    import numpy as np
    a = np.array([1,2,3])
    b = np.array([[1],[2],[3]])
    

I want to convert b to a. Is there any quick way to do that?


Answer: There are a lot of ways you could do that, such as indexing:

    
    
    a = b[:, 0]
    

raveling:

    
    
    a = numpy.ravel(b)
    

or reshaping:

    
    
    a = numpy.reshape(b, (-1,))
    

