import numpy as np
cube = np.array([[[1,2], [3, 4]], [[5, 6], [7, 8]]]) print(cube)
[[[1 2] [3 4]] [[5 6] [7 8]]]
cube.ndim
3
cube.shape
(2, 2, 2)
cube[1, 1, 1]
8
cube[0, 0]
array([1, 2])
Or, equivalently (as a trailing : is always implied):
:
cube[0, 0, :]
cube[:, 0, 1]
array([2, 6])
cube[:, 1, :]
array([[3, 4], [7, 8]])