Daniel Wu
Daniel Wu

Reputation: 6003

How to combine 2 numpy.ndarray in numpy

I have the following 2 arrays:

k=arange(1,100)
m=arange(1,100)

Then how to append or combine them into an array with 2 columns and 99 rows?

Upvotes: 2

Views: 2361

Answers (1)

Miikka
Miikka

Reputation: 4653

vstack, hstack and transpose are your friends for things like this.

>>> vstack([k,m]).transpose()
array([[ 1,  1],
       [ 2,  2],
       [ 3,  3],
       ...
       [98, 98],
       [99, 99]])

Upvotes: 6

Related Questions