I have an unknown 2D numpy array like the following:
a = np.array([
[1, 2],
[0, 2],
])
I want to use the elements of the array as an index to another array b to produce the following effect:
b = np.random.randn(5, 5)
c = b[[1, 2], [0, 2]]
How can I use the variable a to replace the hardcoded values in the index?
Using the following code did not work:
b = np.random.randn(5, 5)
c = [*a]
As the * expression is used in an index.
aalways equal to2?