Creating Arrays
import numpy as np
1D array
# 1D array
a = np.array([1, 2, 3])
a
array([1, 2, 3])
a.shape
(3,)
2D array
# 2D array
b = np.array([(1.5, 2, 3), (4, 5, 6)])
b
array([[1.5, 2. , 3. ],
[4. , 5. , 6. ]])
b.shape
(2, 3)
3D array
c = np.array([
[(1.5, 2, 3), (4, 5, 6)],
[(3, 2, 1), (4, 5, 6)]
])
c
array([[[1.5, 2. , 3. ],
[4. , 5. , 6. ]],
[[3. , 2. , 1. ],
[4. , 5. , 6. ]]])
c.shape
(2, 2, 3)