Convert list to matrix Python
Ngày đăng:
20/12/2021
Trả lời:
0
Lượt xem:
122
Show convert list of lists to numpy matrix code exampleExample 1: 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]])Example 2: convert list of lists to numpy array matrix pythonx=[[1,2],[1,2,3],[1]] y=numpy.array([numpy.array(xi) for xi in x]) type(y) # |