0

I'm quite new in Numpy and I don´t know how to solve this problem.

I have these arrays:

one = np.array(np.ones(3))   --> [ 1.  1.  1.]
two = np.array(np.zeros(3))  --> [ 0.  0.  0.]
three = np.array([1,2,3]) -->    [ 1  2  3]

I would like to create an array that holds these three arrays in this way:

[[ 1.  1.  1.]
 [ 0.  0.  0.]
 [ 1.  2.  3.]]

thanks

1
  • 2
    np.array([one, two, three])? Commented Feb 25, 2015 at 9:57

2 Answers 2

1
>>> import numpy as np
>>> one=np.array(np.ones(3))
>>> two=np.array(np.zeros(3))
>>> three=np.array([1,2,3])
>>> one
array([ 1.,  1.,  1.])
>>> two
array([ 0.,  0.,  0.])
>>> three
array([1, 2, 3])
>>> matrix=np.array([one,two,three])
>>> matrix
array([[ 1.,  1.,  1.],
       [ 0.,  0.,  0.],
       [ 1.,  2.,  3.]])
>>> 
Sign up to request clarification or add additional context in comments.

Comments

0
np.vstack((one, two, three))

Read about vstack here

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.