I have a list in python and I want to convert it to an array to be able to use ravel()
function.
To convert a list to array in Python, use the np. array() method. The np. array() is a numpy library function that takes a list as an argument and returns an array containing all the list elements.
We can use numpy ndarray tolist() function to convert the array to a list.
Use numpy.asarray
:
import numpy as np myarray = np.asarray(mylist)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With