Issue
I have p = [1,2,3,4]
. I would like a 100x4 numpy matrix with p
in each row. What's the best way to create that?
I tried pvect = np.array(p for i in range(10))
but that doesn't seem to be right.
Thanks
Solution
Use numpy.tile
:
pvect = np.tile(p, (100, 1))
output:
array([[1, 2, 3, 4],
[1, 2, 3, 4],
...
[1, 2, 3, 4],
[1, 2, 3, 4]])
Answered By - mozway
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.