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.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I have two numpy arrays such as:
a = np.array([1, 2, 3]) b = np.array([101, 102, 103 ])
I want to create a new array with shape (len(a), 2), such as
array([[1, 101], [2, 102], [3, 103]])
How can I do it with numpy?
This is so called column_stack
column_stack
np.column_stack((a,b)) Out[309]: array([[ 1, 101], [ 2, 102], [ 3, 103]])
Add a comment
Alternatively:
np.c_[a,b]
will do the job as well.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.