Articles → NUMPY → Arrays In Numpy
Arrays In Numpy
Arrays
- Vectors
- Matrices
Vectors
import numpy as np
my_list = [1,2,3]
my_list
print(np.array(my_list))
Click to Enlarge
Matrices
import numpy as np
my_matrix = [[1,2,3],[4,5,6],[7,8,9]]
print(np.array(my_matrix))
Click to Enlarge
Accessing The Elements In Matrices
- Double bracket approach
import numpy as np
my_matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])
# double bracket approach
print(my_matrix[0][1])
- Single bracket approach
import numpy as np
my_matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])
# single bracket approach
print(my_matrix[0, 1])