I have a numpy nd array with the following shape as an example:
import numpy as np
# Note this can be variable and have different dimensions each time
shape = [100, 100, 100, 5]
array = np.zeros(shape)
Now what I want to do is address the last dimension, so I need something like:
array[:, :, :, i] = something
But I cannot hard code it like this as the dimensions can change depending on the input. So is there a way to index the last dimension of an nd-array?