List to array conversion to use ravel() function

user2229953 picture user2229953 · Apr 8, 2013 · Viewed 624.9k times · Source

I have a list in python and I want to convert it to an array to be able to use ravel() function.

Answer

A. Rodas picture A. Rodas · Apr 8, 2013

Use numpy.asarray:

import numpy as np
myarray = np.asarray(mylist)