List to array conversion to use ravel() function

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


Solution 1:

Use numpy.asarray:

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

Solution 2:

create an int array and a list

from array import array
listA = list(range(0,50))
for item in listA:
    print(item)
arrayA = array("i", listA)
for item in arrayA:
    print(item)