numpy multi-dimensional array

·

1 min read

The useful thing about numpy is it can create a multi-dimensional array.

a_mul = np.array([[1,2,3], [4,5,6], [7, 8, 9]])
print(a_mul)

[[1 2 3]
 [4 5 6]
 [7 8 9]]

If I print(a_mul[0, 1]), what would I get? This means the first row, second column. So, it should be 2.

Likewise, you can print a_mul.shape.

This should return (3, 3) because it is the matrix has three rows and three columns.