Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Given a numpy matrix a of shape (5,3), and a index vector b of shape (5,), where each entry in the index vector is between 0 to 2, how can I create a new vector c based on a and its index vector b.
a
(5,3)
b
(5,)
c
Use arange for the other dimension:
arange
c = a[np.arange(5), b]
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.