Answers for "list of lists to array python"

7

convert list to array python

import numpy as np
my_list = [2,4,6,8,10]
my_array = np.array(my_list)
# printing my_array
print my_array
# printing the type of my_array
print type(my_array)
Posted by: Guest on May-21-2020
2

python convert list of lists to array

# Basic syntax:
numpy.array(list_of_lists)

# Example usage:
import numpy as np
list_of_lists = [[1, 2, 3], [4, 5, 6]] # Create list of lists
your_array = np.array(list_of_lists) # Convert list of lists to array
your_array
--> array([[1, 2, 3],
           [4, 5, 6]])
Posted by: Guest on December-15-2020
0

convert list of lists to numpy array matrix python

x=[[1,2],[1,2,3],[1]]
y=numpy.array([numpy.array(xi) for xi in x])
type(y)
# <type 'numpy.ndarray'>
type(y[0])
# <type 'numpy.ndarray'>
Posted by: Guest on September-28-2020
3

python array to list

a = np.array([1, 2])
list(a)
Posted by: Guest on May-10-2020

Code answers related to "list of lists to array python"

Python Answers by Framework

Browse Popular Code Answers by Language