Reputation: 111
import numpy as np
a = np.array([4, 3, 2, 1])
b = np.array([1, 2, 4, 3])
c = np.stack((a, b))
i = np.array([0, 1])
print(c[i])
I got:
[[4 3 2 1]
[1 2 4 3]]
but my expectd output:
[4 2]
How can I implement this?
Upvotes: 0
Views: 46
Reputation: 11
What do you want to achieve here?
c = [[4 3 2 1] [1 2 4 3]];
from np.stack call
[c[0][0],c[1][1]]
returns [4 2]
which is what you want.
Upvotes: 1